Skip to content

Instantly share code, notes, and snippets.

@dellow
Last active October 5, 2021 10:10
Show Gist options
  • Select an option

  • Save dellow/09e04e826352b011798b to your computer and use it in GitHub Desktop.

Select an option

Save dellow/09e04e826352b011798b to your computer and use it in GitHub Desktop.
Multi dimensional in_array().
/**
* 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