YouTip LogoYouTip

Func String Mb_Substr

# PHP mb_substr() Function [![Image 3: PHP String Reference](#) PHP String Reference](#) ## Example Return "Newbie from the string: * * * ## Definition and Usage The mb_substr() function returns a part of a string. We previously learned the substr() function, which only works for English characters. To split Chinese text, you need to use mb_substr(). **Note:** If the start parameter is negative and length is less than or equal to start, then length is 0. * * * ## Syntax mb_substr ( string $str , int $start [, int $length = NULL [, string $encoding = mb_internal_encoding() ]] ) : string | Parameter | Description | | --- | --- | | _str_ | Required. The string to extract the substring from. | | _start_ | Required. Specifies where to start in the string. * Positive number - Start at a specified position in the string * Negative number - Start at a specified position from the end of the string * 0 - Start at the first character in the string | | _length_ | Optional. Specifies the length of the string to return. Default is until the end of the string. * Positive number - Return from the position specified by the start parameter * Negative number - Stop at the specified number of characters from the end of the string | | encoding | Optional. Character encoding. If omitted, the internal character encoding is used. | ## Technical Details | Return Value: | Returns the extracted part of the string, or FALSE on failure, or an empty string. | | :--- | | PHP Version: | 4+ | * * PHP String Reference](#)
← C Function StrstrC Function Strrchr β†’