+4 votes
in Programming Languages by (59.4k points)
I want to do a case-insensitive search of a substring in a string. What PHP function should I use?

1 Answer

+2 votes
by (40.5k points)
selected by
Best answer

You can use PHP function stripos() to find the position of the first occurrence of a substring inside a string. stripos() can be used for a case-insensitive search.


$string1 = "Hello Everybody, where ArE you?";
$substring1 = "everybody";

if (stripos($string1, $substring1) === False)
    echo "Not Found";
    echo "Found<br />";
    echo stripos($string1, $substring1);