Home >Backend Development >PHP Tutorial >Simple method to intercept php string_PHP tutorial

Simple method to intercept php string_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:01:06752browse

Copy code The code is as follows:

strpos(string,find,start)

Example :
Copy code The code is as follows:



Output 6
Copy code The code is as follows:

substr(string ,start,length)

where the parameters of start

Positive number - starts at the specified position in the string
Negative number - starts at the specified position from the end of the string
0 - starts at the first character in the string

Copy code The code is as follows:



Output world

The strstr() function searches for the first occurrence of a string within another string.

This function returns the rest of the string (from the matching point). Returns false if the searched string is not found.

Copy code The code is as follows:

strstr('abc@jb51.net', '@', TRUE); / /Parameter set to true, returns the header before the search value @, abc
strstr('abc@jb51.net', '@'); //By default, returns the tail after the search value @, @jb51.net

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/328009.htmlTechArticleCopy the code as follows: strpos(string,find,start) Example: Copy the code as follows: ?php echo strpos ("Hello world!","wo"); ? Output 6 Copy code The code is as follows: substr(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