Skip to content

Instantly share code, notes, and snippets.

@tnrn9b
Forked from dflima/array_search_key.php
Created April 17, 2017 04:52
Show Gist options
  • Select an option

  • Save tnrn9b/252fd51aadf670ef9c459647684331ae to your computer and use it in GitHub Desktop.

Select an option

Save tnrn9b/252fd51aadf670ef9c459647684331ae to your computer and use it in GitHub Desktop.
<?php
use Illuminate\Support\Arr;
function array_multi_search(array $array, $key)
{
if (!is_string($key)) {
return false;
}
$array = array_keys(Arr::dot($array));
return array_reduce($array, function ($carry, $item) use ($key) {
return strpos($item, $key) || $carry;
}, false);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment