This article describes the example of PHP using the strstr() function to get all the characters after the specified string. Character method. Share it with everyone for your reference, the details are as follows:
PHP’s strstr() function can search for the first occurrence of a string in another string and return the remaining part of the string.
strstr() function is defined as follows:
strstr(string,search,before_search)
Parameter description:
string Required. Specifies the string to be searched for.
search
Required. Specifies the string to be searched for.
If this argument is a number, searches for characters that match the ASCII value for this number.
before_search
Optional. The default value is a Boolean value of "false".
If set to "true", it returns the portion of the string preceding the first occurrence of the search parameter.
The sample code is as follows:
<?php echo strstr("欢迎来到帮客之家","脚本"); echo "<br/>"; echo strstr("Welcome To www.jb51.net","jb51"); echo "<br/>"; echo strstr("123456789","5"); ?>
The running results are as follows:
帮客之家 jb51.net 56789
Supplement:
The third optional parameter of strstr() function can only be used after PHP5.3 version, such as:
echo strstr("123456789","5",true); //输出:1234
For more information on PHP string operations, please view the special topic on this site: "Summary of PHP String Usage"
I hope this article will be helpful to everyone in PHP programming.