Skip to content

Instantly share code, notes, and snippets.

@SofHad
Created October 31, 2013 09:08
Show Gist options
  • Save SofHad/7246561 to your computer and use it in GitHub Desktop.
Save SofHad/7246561 to your computer and use it in GitHub Desktop.
in_array() and multidimensional array
public function inMultiDimensionalArray($needle, $haystack, $strict = false) {
foreach ($haystack as $item) {
if (($strict ? $item === $needle : $item == $needle) || (\is_array($item) && $this->inMultidimensionalArray($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