1 redirect.module redirect_compare_array_recursive($match, $haystack)

Compare that all values and associations in one array match another array.

We cannot use array_diff_assoc() here because we need to be recursive.

Parameters

$match: The array that has the values.

$haystack: The array that will be searched for values.

Return value

bool: TRUE if all the elements of $match were found in $haystack, or FALSE otherwise.

File

core/modules/redirect/redirect.module, line 1057

Code

function redirect_compare_array_recursive($match, $haystack) {
  foreach ($match as $key => $value) {
    if (!array_key_exists($key, $haystack)) {
      return FALSE;
    }
    elseif (is_array($value)) {
      if (!is_array($haystack[$key])) {
        return FALSE;
      }
      elseif (!redirect_compare_array_recursive($value, $haystack[$key])) {
        return FALSE;
      }
    }
    elseif ($value != $haystack[$key]) {
      return FALSE;
    }
  }
  return TRUE;
}