SoFunction
Updated on 2025-03-09

『PHP』 Introduction to the use of PHP truncation function mb_substr

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

$str, a string that needs to be truncated
$start, the beginning of the truncation
$length, length (note that this is different from mb_strimwidth, 1 represents a Chinese character)
$encoding, encoding, I set it to utf-8

Example: Cut off the title of the article and control it to 15 texts