Case insensitive array_search() with partial matches
<?php
/**
* Case insensitive array_search() with partial matches.
*
* @param string $needle
* @param array $haystack
* @return bool|int|string
*/
public static function array_find( $needle, array $haystack ) {
$found = false;
foreach ( $haystack as $key => $value ) {
if ( false !== stripos( $needle, $value ) ) {
$found = $key;
break;
}
}
return $found;
}