Created
June 22, 2014 15:47
-
-
Save Billy-/bc6865066981e80e097f to your computer and use it in GitHub Desktop.
in_array_r() - a multidimensional version of PHP's in_array()
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
function in_array_r($needle, $haystack, $strict = false) { | |
foreach ($haystack as $item) { | |
if (($strict ? $item === $needle : $item == $needle) || (is_array($item) && in_array_r($needle, $item, $strict))) { | |
return true; | |
} | |
} | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage:
http://stackoverflow.com/a/4128377/1879895