Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (!(is_array($a1) and (is_array($a2)))) { return FALSE;}
- if (!count($a1) == count($a2))
- {
- return FALSE; // arrays don't have same number of entries
- }
- foreach ($a1 as $key => $val)
- {
- if (!array_key_exists($key, $a2))
- {return FALSE; // uncomparable array keys don't match
- }
- elseif (is_array($val) and is_array($a2[$key])) // if both entries are arrays then compare recursive
- {if (!array_compare_recursive($val,$a2[$key])) return FALSE;
- }
- elseif (!($val === $a2[$key])) // compare entries must be of same type.
- {return FALSE;
- }
- }
- return TRUE; // $a1 === $a2
Add Comment
Please, Sign In to add comment