There is a very important technology in php, which is to intercept characters of a specified length in a specified string . PHP can use the PHP pre-defined function substr() function to intercept strings. I believe everyone is very clear about this, so what other methods do I have?
The code is as follows:strpos(string,find,start)
<?php echo strpos("Hello world!","wo"); ?>
substr(string,start,length)
Negative number - starts at the specified position from the end of the string
0 - at the specified position of the string Starting at the first character in
<?php echo substr("Hello world!",6,5); ?>
SearchA string in The first occurrence in another string.
This function returns the rest of the string (from the matching point). Returns false if the searched string is not found.strstr('abc@jb51.net', '@', TRUE); //参数设定true, 返回查找值@之前的首部, abcstrstr( 'abc@jb51.net', '@'); //默认返回查找值@之后的尾部,@jb51.net
Summary:
I believe that by studying this article, you will be able to intercept PHP I have a certain understanding and understanding of strings, I hope it will be helpful to your work!Related recommendations:
PHP interception string function substr() function example usage detailed explanation
php intercepts string (no garbled utf8)
php intercepts string function, php customString interceptionMethod
The above is the detailed content of Introduction to the method of intercepting strings in php. For more information, please follow other related articles on the PHP Chinese website!