We use the
PHP stristr() function to find the first occurrence of a string in another string.
Definition and Usage The PHP stristr() function finds the first occurrence of a string in another string. If successful, the remainder of the string (from the point of the match) is returned. If the string is not found, returns false.
Syntax stristr(string,search)
Parameters and descriptions
string required. Specifies the string to be searched for.
find required. Specifies the characters to search for. If the argument is a number, searches for characters that match the ASCII value for that number.
Tips and Notes Note: This function is binary safe.
Note: This function is not case sensitive. For case-sensitive searches, use strstr().
PHP stristr() function example 1
<ol class="dp-xml"><li class="alt"><span><span class="tag"><</span><span> ?php </span></span></li><li><span>echo stristr("Hello world!","WORLD"); </span></li><li class="alt"><span> </span></li><li><span class="tag">?></span><span> </span></span></li></ol>
Output:
world!
PHP stristr() function example 2
<ol class="dp-xml"> <li class="alt"><span><span class="tag"><</span><span> ?php </span></span></li><li><span>echo stristr("Hello world!",111); </span></li><li class="alt"><span class="tag">?></span><span> </span></span></li> <li><span> </span></li> </ol>
Output:
o world!