You are here

function imageinfo_cache_array_diff_assoc_recursive in Imageinfo Cache 7.3

Computes the difference of arrays with additional index check recursively.

Parameters

array $array1: The array to compare from.

array $array2: An array to compare against.

Return value

array Returns an array containing all the values from array1 that are not present in any of the other arrays.

1 call to imageinfo_cache_array_diff_assoc_recursive()
imageinfo_cache_get_image_styles_in_views in ./imageinfo_cache.inc
Given a field name, will return image styles used in views for that field.

File

./imageinfo_cache.inc, line 444
Imageinfo Cache module. Helper functions.

Code

function imageinfo_cache_array_diff_assoc_recursive(array $array1, array $array2) {
  foreach ($array1 as $key => $value) {
    if (is_array($value)) {
      if (!isset($array2[$key])) {
        $difference[$key] = $value;
      }
      elseif (!is_array($array2[$key])) {
        $difference[$key] = $value;
      }
      else {
        $new_diff = imageinfo_cache_array_diff_assoc_recursive($value, $array2[$key]);
        if ($new_diff != FALSE) {
          $difference[$key] = $new_diff;
        }
      }
    }
    elseif (!isset($array2[$key]) || $array2[$key] != $value) {
      $difference[$key] = $value;
    }
  }
  return !isset($difference) ? 0 : $difference;
}