PHP uses the strstr() function to obtain all characters after a specified string, strstr string_PHP tutorial

WBOY
Release: 2016-07-12 09:01:21
Original
1395 people have browsed it

PHP uses the strstr() function to get all the characters after the specified string. strstr string

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:

<&#63;php
 echo strstr("欢迎来到帮客之家","脚本");
 echo "<br/>";
 echo strstr("Welcome To www.jb51.net","jb51");
 echo "<br/>";
 echo strstr("123456789","5");
&#63;>

Copy after login

The running results are as follows:

帮客之家
jb51.net
56789

Copy after login

Supplement:

The third optional parameter of strstr() function can only be used after PHP5.3 version, such as:

echo strstr("123456789","5",true);
//输出:1234

Copy after login

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.

Articles you may be interested in:

  • How to get the number of occurrences of a substring with the substr_count() function in PHP
  • The strncmp() function in PHP compares two strings How to determine whether the first two characters are equal
  • Strnatcmp() function "Natural Sorting Algorithm" in PHP for string comparison usage analysis (compare strcmp function)
  • strcmp() and strcasecmp() in PHP )Usage analysis of function string comparison
  • Usage analysis of substr function string interception in PHP
  • PHP uses the trim function to remove left and right spaces and special characters from a string. Example
  • PHP encapsulated String encryption and decryption function
  • The most accurate PHP function to intercept string length
  • What to do if the problem of Chinese garbled characters occurs when substr() is used to intercept strings in PHP
  • Commonly used in PHP Summary of String Operation Function Examples

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1089573.htmlTechArticlePHP uses the strstr() function to obtain all the characters after the specified string. The strstr string is an example of PHP. Use the strstr() function to obtain all characters after a specified string. Points...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template