stristr(): finding first occurance of a sting
Required: Input string ( main string for searching )
Required: used to search the first occurance inside Input string
Optional: default FALSE, if set to TRUE then output returns the string before the first occurrence of $needle ( excluding the $needle )
This is case in-sensitive search. Use strstr() for case sensitive search
Example 1 of strstr()
Example 2 of strstr()
Example 3 of strstr()
Uses of strstrWe can find out existence of a word or combination of words in a string. For example we don't want some words to be posted by the user while submitting any message or text to the system. We can check the existence of the word by using stristr() function and know the presence of the string. This is case insensitive checking.
For a case sensitive checking we can use strstr function
stristr function is used to check the presence of https:// in the posted message. Or it can be checked the presence of <a in the posted string to identify a link. Here is the syntax of this function.
string stristr (main string , checking string)
This function returns true if the checked string is found within the main string. Now here is a code which uses stristr function and returns true after checking the word.
We can also use split command to get the domain part from email address.
Searching Blank space inside a string
The output is
This article is written by plus2net.com team.