Hello everyone. I'm having an issue comparing strings:
I am trying to find a case insensitive PHP function that checks if a string is a part of another string. For instance if you compare "Hello my Name is Teo" with "my nAMe" it would return true or 1. Is there something like this? I have a huge list of string functions but I can't find something that works...
Kindly listen to the advice posted by others before claiming resolution.
substr_count() returns the number of times the needle substring occurs in the haystack string. Please note that needle is case sensitive.
Your original question was quite clear in stating you wanted a case insensitive comparison, you even put that in upper case to emphasize.
stripos(), available in PHP5, is case insensitive, strpos is not. Also, just so you know, the function you used doesn't count overlapped substrings and stripos is also binary safe, which can be handy in some situations.
Sorry, but had to post this, no disrespect intended.