This example describes how PHP uses the Strstr () function to get all the characters after the specified string. Share to everyone for your reference, specific as follows:
The Strstr () function of PHP searches for the first occurrence of a string in another string, and returns the remainder of the string.
The Strstr () function is defined as follows:
Strstr (String,search,before_search)
Parameter description:
String required. Specify the string to be searched for.
Search
Necessary. Specify the string to search for.
If this parameter is a number, search for characters that match the ASCII value of this number.
Before_search
Optional. The default value is a Boolean value of ' false '.
If set to True, it returns the part of the string before the search parameter first appears.
The sample code is as follows:
<?php
Echo strstr ("Welcome to the cloud-dwelling community", "script");
echo "<br/>";
Echo strstr ("Welcome to Www.jb51.net", "jb51");
echo "<br/>";
Echo strstr ("123456789", "5");
? >
The results of the operation are as follows:
Cloud-dwelling Community
jb51.net
56789
Add:
You can use the third optional parameter of the STRSTR () function after the PHP5.3 version, such as:
Echo strstr ("123456789", "5", true);
Output: 1234
More about PHP string operations related to the site to see the topic: "PHP string (String) Usage Summary"
I hope this article will help you with the PHP program design.