How to make strpos case insensitive How to make strpos case insensitive php php

How to make strpos case insensitive


You're looking for stripos()

If that isn't available to you, then just call strtolower() on both strings first.

EDIT:

stripos() won't work if you want to find a substring with diacritical sign.

For example:

stripos("Leży Jerzy na wieży i nie wierzy, że na wieży leży dużo JEŻY","jeży"); returns false, but it should return int(68).


'i' in stripos() means case insensitive

if(stripos($product->name, $searchterm) !== false){ //'i' case insensitive        echo "Match = ".$product->link."<br />;    }