Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save masterfermin02/6d26d3fbde2a6e1695382b9bf04dc728 to your computer and use it in GitHub Desktop.
Save masterfermin02/6d26d3fbde2a6e1695382b9bf04dc728 to your computer and use it in GitHub Desktop.
<?php
function searchMultiDimensionalArray($array, $key, $value) {
if(!is_array($array)) {
return preg_match("/$value/i", $array);
}
return array_filter($array, function($item) use ($key, $value){
return (isset($item[$key]) && !is_array($item[$key]) && preg_match("/$value/i", $item[$key]))
|| searchMultiDimensionalArray($item, $key, $value);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment