-
-
Save Mario-Duarte/d9de8b9338331feeac17b07b9766e27f to your computer and use it in GitHub Desktop.
Check if a value exists in an array/object.
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
| /** | |
| * Check if a value is in a multi-dimensional array | |
| * @param mixed $needle The value that you are searching for | |
| * @param array $haystack The multi-dimensional array to search | |
| * @param boolean $strict Whether to use strict search or not | |
| * @return boolean Whether the value was found or not | |
| */ | |
| function in_multi_array($needle, $haystack, $strict=false) { | |
| foreach ($haystack as $subhaystack) { | |
| if(in_array($needle, $subhaystack, $strict)) | |
| return true; | |
| } | |
| return false; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment