Home  >  Article  >  Backend Development  >  How to use PHP stristr() function for character search_PHP tutorial

How to use PHP stristr() function for character search_PHP tutorial

WBOY
WBOYOriginal
2016-07-15 13:33:19958browse

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!


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/446087.htmlTechArticleWe use the PHP stristr() function to find the first occurrence of a string in another string Location. Definition and Usage PHP stristr() function finds the first string in another string...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn