strpos strrchr strpbrk character search function in php

高洛峰
Release: 2016-11-29 13:32:11
Original
1537 people have browsed it

strpos() function returns the position of the first occurrence of a string in another string. If the string is not found, it returns false.

Syntax: strpos(string,find,start), the code is as follows:

$str="hello world"; //Define string 1

$result=strpos($str,"ll"); The

strrchr() function finds the last occurrence of a string in another string and returns all characters from that position to the end of the string. If it fails, it returns false otherwise.

Syntax: strrchr(string,char ), the code is as follows:

$str="hello world"; //Define string 1

$result=strrchr($str,"o"); ;

strpbrk() function searches for any one of the specified characters in the string. The function returns the remaining part starting from the first occurrence of the specified character. If it is not found, it returns false.

Syntax: strpbrk(string , charlist), the code is as follows:

$str="hello world"; //Define string 1

$result=strpbrk($str,"oe"); //Perform search operation

echo $result; /Output results, ello world

//Open source code phpfensi.com

Tips and comments.

Note: This function is case-sensitive.

Related labels:
php
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!