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