Voting

: max(zero, eight)?
(Example: nine)

The Note You're Voting On

rhallsey at yahoo dot com
10 years ago
Here's a simple function that returns true if all keys in the first array are found in the second array, and false if they aren't.

function same_keys ($a1, $a2) {
$same = false;
if (!array_diff_key($a1, $a2)) {
$same = true;
foreach ($a1 as $k => $v) {
if (is_array($v) && !same_keys($v, $a2[$k])) {
$same = false;
break;
}
}
}
return $same;
}

To check if two arrays have the same structure, ignoring values, execute the function twice, the second time with the arguments reversed.

<< Back to user notes page

To Top