English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Returns "Basic Tutorial" from the string:
<?php echo mb_substr("Basic Tutorial Website", 0, 4); // Output: Tutorial Tutorial ?>Test and see ‹/›
The mb_substr() function returns a part of the string. We have learned about the substr() function before, which is only for English characters. If you need to split Chinese characters, you need to use mb_substr().
Note:If the start parameter is negative and the length is less than or equal to start, then length is 0.
mb_substr(string $str, int $start[, int $length = NULL[, string $encoding = mb_internal_encoding()]]): string
Parameters | Description |
---|---|
str | Required. Extract a substring from this string. |
start | Required. Specify where to start in the string.
|
length | Optional. Specify the length of the string to return. The default is to the end of the string.
|
encoding | Optional. Character encoding. If omitted, the internal character encoding is used. |
Return value: | Returns the extracted part of the string, or FALSE if the operation fails, or an empty string. |
---|---|
PHP Version: | 4+ |