Return to Snippet

Revision: 60866
at November 14, 2012 11:10 by kosinix


Initial Code
function in_array_str_i($key, $array){
    foreach($array as $element){
        if(strcasecmp($key, $element)==0){
            return true;
        }
    }
    return false;
}

$array = array(
    'string1',
    'string2',
    'StriNg3'
);

var_dump(in_array_str_i('string3', $array)); //bool(true). returns true

Initial URL

                                

Initial Description
Use it similar to in_array function of PHP.

Initial Title
PHP Search String in Array - Case Insensitive

Initial Tags
php, search, array

Initial Language
PHP