Skip to content

Instantly share code, notes, and snippets.

@karlgroves
Created March 23, 2013 11:55
Show Gist options
  • Save karlgroves/5227442 to your computer and use it in GitHub Desktop.
Save karlgroves/5227442 to your computer and use it in GitHub Desktop.
Determines if two arrays are identical.
/**
* compares two arrays to check if they're identical
* @param array $op1 the first array
* @param array $op2 the second array
* @return bool
*/
function arrayIdentical($op1, $op2) {
if (count($op1) < count($op2)) {
return FALSE;
// $op1 < $op2
} elseif (count($op1) > count($op2)) {
return FALSE;
// $op1 > $op2
}
foreach ($op1 as $key => $val) {
if (!array_key_exists($key, $op2)) {
return FALSE;
// uncomparable
} elseif ($val < $op2[$key]) {
return FALSE;
} elseif ($val > $op2[$key]) {
return FALSE;
}
}
return TRUE;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment