Created
July 31, 2014 08:49
-
-
Save johnroyer/c744e20685f939595698 to your computer and use it in GitHub Desktop.
Array Compare Recursively
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Compare if two array are totally the same | |
* | |
* @return bool | |
*/ | |
function isArraySameRecursively($o, $c){ | |
if(count(array_diff_assoc($o, $c)) > 0){ | |
return false; | |
} | |
foreach($o as $key => $elem){ | |
if(is_array($elem)){ | |
if(isArraySameRecursively($o[$key], $c[$key]) == false){ | |
return false; | |
} | |
} | |
} | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment