function features_array_diff_assoc_recursive in Features 7.2
Recursively computes the difference of arrays with additional index check.
This is a version of array_diff_assoc() that supports multidimensional arrays.
Parameters
array $array1: The array to compare from.
array $array2: The array to compare to.
Return value
array Returns an array containing all the values from array1 that are not present in array2.
3 calls to features_array_diff_assoc_recursive()
- features_export_prepare in ./
features.export.inc - Prepares a feature export array into a finalized info array.
- field_base_features_rebuild in includes/
features.field.inc - Implements of hook_features_rebuild(). Rebuilds fields from code defaults.
- field_features_rebuild in includes/
features.field.inc - Implements of hook_features_rebuild(). Rebuilds fields from code defaults.
File
- ./
features.module, line 1394 - Main *.module file for the 'features' module.
Code
function features_array_diff_assoc_recursive(array $array1, array $array2) {
$difference = array();
foreach ($array1 as $key => $value) {
if (is_array($value)) {
if (!isset($array2[$key]) || !is_array($array2[$key])) {
$difference[$key] = $value;
}
else {
$new_diff = features_array_diff_assoc_recursive($value, $array2[$key]);
if (!empty($new_diff)) {
$difference[$key] = $new_diff;
}
}
}
elseif (!isset($array2[$key]) || $array2[$key] != $value) {
$difference[$key] = $value;
}
}
return $difference;
}