How to check if array contains string case insensitive in PHP

To check if array contains string case insensitive in PHP you can use the following snippet.

function ArrayContainsStringCaseInsensitve($searchString, $array){
    foreach($array as $element){
        if(strcasecmp($searchString, $element)==0){
            return true;
        }
    }
    return false;
}

Please Share us:
Please rate this snippet

One thought on “How to check if array contains string case insensitive in PHP

Leave a Reply