PHP uses the strstr () function to obtain all characters after a specified string. strstr string _ PHP Tutorial

Source: Internet
Author: User
PHP uses the strstr () function to obtain all characters after a specified string, strstr string. PHP uses the strstr () function to obtain all characters after a specified string. This document describes how PHP uses the strstr () function to obtain all characters after a specified string. Use the strstr () function in PHP to obtain all characters after a specified string.

This example describes how PHP uses the strstr () function to obtain all characters after a specified string. 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 the customer's house", "script"); echo"
"; Echo strstr (" Welcome To www.jb51.net "," jb51 "); echo"
"; Echo strstr (" 123456789 "," 5 ");?>

The running result is as follows:

Helper House jb51.net56789

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.