Reputation: 147
I want to find out whether the input string is a substring of another string or not , is there any function that do so ignoring case sensitivity? The substring check should be done ignoring case sensitivity. Please tell me about any such function
Upvotes: 1
Views: 300
Reputation: 13303
You can also use stripos
Find the position of the first occurrence of a case-insensitive substring in a string
if(stripos("This is a test string","A Test")!==FALSE)
{
echo "Yes";
}
Check this note for stristr from manual:
Note: If you only want to determine if a particular needle occurs within haystack, use the faster and less memory intensive function strpos() instead.
Upvotes: 1
Reputation: 46900
Use stristr
Returns the matched substring. If needle is not found, returns FALSE.
if(stristr("Hello","hello world")!==FALSE)
{
// Yes needle is a part of haystack
}
Upvotes: 2