Skip to content

Instantly share code, notes, and snippets.

@AlexH-HankIT
Forked from branneman/gist:951847
Last active August 29, 2015 14:27
Show Gist options
  • Select an option

  • Save AlexH-HankIT/9ff8af0a7c246e36d7bd to your computer and use it in GitHub Desktop.

Select an option

Save AlexH-HankIT/9ff8af0a7c246e36d7bd to your computer and use it in GitHub Desktop.
array_find() - A case insensitive array_search() with partial matches
<?php
/**
* Case in-sensitive array_search() with partial matches
*
* @param string $needle The string to search for.
* @param array $haystack The array to search in.
*
* @author Bran van der Meer <[email protected]>
* @since 29-01-2010
*/
public function array_find($needle, array $haystack)
{
foreach ($haystack as $key => $value) {
if (false !== stripos($value, $needle)) {
return $key;
}
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment