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;
}

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

Leave a Reply