public static function arraySearch($needle, array $haystack, $caseSensitive = true)
    {
        foreach ($haystack as $key => $value) {
            $searchFunc = ($caseSensitive) ? 'strpos' : 'stripos';

            if ($searchFunc($value, $needle) === 0) {
                return $key;
            }
        }

        return false;
    }
public static function arraySearch($needle, array $haystack, $caseSensitive = true)
    {
        foreach ($haystack as $key => $value) {
            $searchFunc = ($caseSensitive) ? 'strpos' : 'stripos';

            if ($searchFunc($value, $needle) === 0) {
                return $key;
            }
        }

        return false;
    }
public static function arraySearch ( $ needle , array $ haystack , $ caseSensitive = true ) { foreach ( $ haystack as $ key => $ value ) { $ searchFunc = ( $ caseSensitive ) ? 'strpos' : 'stripos' ; if ( $ searchFunc ( $ value , $ needle ) === 0 ) { return $ key ; } } return false ; }
An improved array_search that allows for partial matching
of strings values in associative arrays.

@param   string  $needle        The text to search for within the array.
@param   array   $haystack      Associative array to search in to find $needle.
@param   boolean $caseSensitive True to search case sensitive, false otherwise.

@return  mixed    Returns the matching array $key if found, otherwise false.

@since   2.0
An improved array_search that allows for partial matching of strings values in associative arrays .