Ignore case sensitivity when comparing strings in PHP

Use str_ireplace to perform a case-insensitive string replacement (str_ireplace is available from PHP 5):

$story_body = str_ireplace($arr_query_words[$j],
   '<span style=" background-color:yellow; ">'. $arr_query_words[$j]. '</span>',
    $story_body);

To case-insensitively compare strings, use strcasecmp:

<?php
$var1 = "Hello";
$var2 = "hello";
if (strcasecmp($var1, $var2) == 0) {
    echo '$var1 is equal to $var2 in a case-insensitive string comparison';
}
?>

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)