PHP mb_substr() Function
Example
Return "Runoob" from a string:
Definition and Usage
The mb_substr() function returns a part of a string. We learned the substr() function earlier, which only works on 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
| Parameters | Description |
|---|---|
| str | Required. The string to extract the substring from. |
| start | Required. Specifies where in the string to start.
|
- Positive - Return from the position of the start parameter
- Negative - Return from the end of the string
Technical Details
| Return Value: | Returns the extracted part of the string, FALSE on failure, or an empty string. |
|---|---|
| PHP Version: | 4+ |
PHP String Reference Manual