``` --- ##"> ``` --- ##" />
Easy Tutorial
❮ Func Simplexml Import Dom Php Filter Advanced ❯

PHP mb_substr() Function

PHP String Reference Manual

Example

Return "tutorialpro" from the string:

<?php
echo mb_substr("tutorialpro.org", 0, 11);
// Output: tutorialpro
?>

Definition and Usage

The mb_substr() function returns a part of a string. Previously, we learned about the substr() function, which only works with English characters. If you need to split Chinese characters, you should use mb_substr().

Note: If the start parameter is negative and length is less than or equal to start, length is set to 0.


Syntax

Parameter Description
str Required. The string to extract the substring from.
start Required. Specifies where to start in the string. Positive - Start at the specified position in the string. Negative - Start at the specified position from the end of the string. 0 - Start at the first character in the string.
length Optional. Specifies the length of the returned string. Default is to the end of the string. Positive - Return from the start parameter position. Negative - Return 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+
--- ---
❮ Func Simplexml Import Dom Php Filter Advanced ❯