Last active
October 5, 2021 10:10
-
-
Save dellow/09e04e826352b011798b to your computer and use it in GitHub Desktop.
Multi dimensional in_array().
This file contains hidden or 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
| /** | |
| * in_arrayr | |
| * Multi dimensional in_array(). | |
| * | |
| * @since 1.0.0 | |
| * @version 1.0.0 | |
| **/ | |
| function in_arrayr($needle, $haystack, $strict = false) { | |
| foreach($haystack as $item){ | |
| if(($strict ? $item === $needle : $item == $needle) || (is_array($item) && in_arrayr($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