Introduction to the specific use of PHP function stristr()_PHP tutorial

WBOY
Release: 2016-07-15 13:30:25
Original
906 people have browsed it

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>
Copy after login

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>
Copy after login

Output:

o world!


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/446289.htmlTechArticleWe will encounter string search situations in actual coding. If we need to find the first occurrence of another string, how should we write it? Today we are...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!