PHP uses the STRSTR () function to get the method of all characters after the specified string _php tips

Source: Internet
Author: User

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.

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.