PHP uses the STRSTR () function to get the method of all characters after the specified string, strstr string
This example describes how PHP uses the Strstr () function to get all the characters after a specified string. Share to everyone for your reference, as follows:
The PHP strstr () function 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 is required. Specifies the string to be searched.
Search
Necessary. Specifies the string to search for.
If this parameter is a number, the character that matches the ASCII value corresponding to this number is searched.
Before_search
Optional. The default value is "false" for a Boolean value.
If set to "true", it returns the string portion of the first occurrence of the search parameter.
The sample code is as follows:
<?php Echo strstr ("Welcome to the House of Help", "script"); echo "
"; Echo strstr ("Welcome to Www.jb51.net", "jb51"); echo "
"; Echo strstr ("123456789", "5");? >
The results of the operation are as follows:
Help the Guest House jb51.net56789
Add:
The third optional parameter of the STRSTR () function can be used after the PHP5.3 version, such as:
Echo strstr ("123456789", "5", true);//output: 1234
Read more about PHP string operations for more information on this site: PHP string Usage Summary
I hope this article is helpful to you in PHP programming.
Articles you may be interested in:
- How the Substr_count () function Gets the number of substrings in PHP
- PHP strncmp () function compares the first 2 characters of a two string method
- STRNATCMP () function "Natural sorting algorithm" in PHP for string comparison usage analysis (compare strcmp function)
- strcmp () and strcasecmp () function strings in PHP comparison usage analysis
- Analysis of substr function string interception usage in PHP
- PHP uses Trim function to remove left and right spaces and special character instances
- PHP encapsulated string encryption and decryption function
- The most accurate PHP intercept string length function
- What to do if you use substr () in PHP to intercept strings in Chinese characters.
- Summary of examples of PHP common string manipulation functions
http://www.bkjia.com/PHPjc/1089573.html www.bkjia.com true http://www.bkjia.com/PHPjc/1089573.html techarticle PHP uses the strstr () function to get the method of all characters after the specified string, strstr the String This example describes how PHP uses the Strstr () function to get all the characters after the specified string. Points ...