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

Source: Internet
Author: User
Tags strcmp

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 ...

  • 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.