PHP

"PHP" PHP truncation function mb_substr of


Function: mb_substr( $str, $start, $length, $encoding )

$str, need to truncate the string $start, where the truncation begins $length, length (note that this is different from mb_strimwidth, where 1 represents 1 Chinese character) $encoding, code, I’m going to say utf-8

Example: truncate the title of the article and limit it to 15 words


<?php echo mb_substr(get_the_title(), 0, 15,"utf-8"); ?>