Home >Backend Development >PHP Tutorial >Detailed explanation of PHP truncation function mb_substr()
In php, the mb_substr() function is a function used to cut Chinese and English characters The mb_substr() function is not supported by default in php. We need to find php.ini in the windows directory, search for mbstring.dll, find ;extension=php_mbstring.dll, and remove the previous; sign before we can use mb_substr () function. Function: mb_substr( $str, $start, $length, $encoding ) Example:
$str="I am a good person!";
$str="I am a good man"; echo mb_substr($str,0,4,'utf-8'); //Result: I am ?> Similar functions: mb_strcut() function
$str="I am a good man"; echo mb_substr($str,0,4,'utf-8'); //Result: I am ?>
$str="I am a good person!"; |