PHP tips for mb_strstr basic PHP Learning Notes

Source: Internet
Author: User
This article mainly introduces the basic use of PHP learning Note mb_strstr, the text through the sample code introduced in very detailed, to everyone's study or work has a certain reference learning value, the need for friends below with the small series to learn together.

Objective

This article mainly introduces the basic use of PHP mb_strstr related content, share out for everyone to reference the study, the following words do not say more, come together to see the detailed introduction bar.

Mb_strstr

    • (PHP 5 >= 5.2.0, PHP 7)

    • Mb_strstr-finds first occurrence of a string within another

    • Finds the first occurrence of a string in another string

Description

String Mb_strstr (  string $haystack,  string $needle [,  bool $before _needle = False [,  string $encoding =m B_internal_encoding ()]]  //mb_strstr () finds the first occurrence of needle in haystack and returns the portion of HA Ystack. If needle is not found, it returns FALSE.//MB_STRSTR () finds the first occurrence of needle in haystack and returns part of Haystack. If needle is not found, it will return FALSE.

Parameters

Haystack

    • The string from which to get the first occurrence of needle

    • The string to get the first occurrence of needle.

Needle

    • The string to find in haystack

    • Look for this string in haystack.

Before_needle

    • Determines which portion of haystack this function returns. If set to TRUE, it returns all of haystack from the beginning to the first occurrence of needle (excluding needle). If set to FALSE, it returns all of haystack from the first occurrence of needle to the end (including needle).

    • Determines which part of the haystack is returned by this function. If set to TRUE, it returns all characters from the beginning to the needle occurrence in haystack (excluding needle). If set to FALSE, it returns all characters (including needle) where needle appears in haystack.

Encoding

    • Character encoding name to use. If it is omitted, internal character encoding is used.

    • The character encoding name to use. If this argument is omitted, the internal character encoding is used.

Return Values

    • Returns the portion of haystack, or FALSE if needle is not found.

    • Returns a portion of the haystack, or FALSE if needle is not found.

Examples

<?php/** * Created by Phpstorm. * User:zhangrongxiang * DATE:2018/2/1 * Time: PM 10:27 *///* * If set to True, it returns all of haystack from the Beginn ing to the first occurrence of needle. $strstr = Mb_strstr ("Hello China", "ll", true); Echo $strstr. Php_eol; he//* If set to False, it returns all of haystack from the first occurrence of needle to the end, $strstr = Mb_strstr ("H Ello China "," ll ", false); Echo $strstr. Php_eol;//llo China//hello chinaecho mb_strstr ("Hello China", "ll", true). Mb_strstr ("Hello China", "ll", false). php_eol; $strstr = mb_strstr ("Hello China,hello PHP", "ll", true); Echo $strstr. Php_eol; He$strstr = Mb_strstr ("Hello China,hello PHP", "ll", false); Echo $strstr. Php_eol; Llo China,hello php$strstr = Mb_strstr ("PHP is the best language in the world

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.