This article mainly introduces how PHP uses the strstr () function to obtain all characters after a specified string, and analyzes strstr () in details based on the instance form () the function is used to intercept strings. For more information about how to use the strstr () function in PHP to obtain all the characters after a specified string, see the following example. We will share this with you for your reference. The details are as follows:
The strstr () function of PHP searches for the first occurrence position of a string in another string and returns the rest of the string.
The strstr () function is defined as follows:
Strstr (string, search, before_search)
Parameter description:
String is required. Specifies the string to be searched.
Search
Required. Specifies the string to be searched.
If this parameter is a number, search for characters matching the ASCII value of this number.
Before_search
Optional. The default value is a Boolean value of "false.
If it is set to "true", it returns the string section before the first appearance of the search parameter.
The sample code is as follows:
<? Php echo strstr ("Welcome to", "script"); echo"
"; Echo strstr (" Welcome To www.bitsCN.com "," jb51 "); echo"
"; Echo strstr (" 123456789 "," 5 ");?>
The running result is as follows:
BitsCN. com56789
Supplement:
The third optional parameter of the strstr () function can be used only after PHP5.3, for example:
Echo strstr ("123456789", "5", true); // output: 1234