We will encounter string search situations in actual encoding. What should we do if we need to find the position of the first occurrence in another string? Today we introduce to you the definition and usage of
PHP function stristr() 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)
Parameter Description
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 function stristr() example 1
<ol class="dp-xml"> <li class="alt"><span><span class="tag"><span> ?php </span></span></span></li> <li><span>echo stristr("Hello world!","WORLD"); </span></li> <li class="alt"> <span class="tag">?></span><span> </span> </li> </ol>
Output:
world!
PHP function stristr() example 2
<ol class="dp-xml"> <li class="alt"><span><span class="tag"><span> ?php </span></span></span></li> <li><span>echo stristr("Hello world!",111); </span></li> <li class="alt"> <span class="tag">?></span><span> </span> </li> </ol>
Output:
o world!