There are many functions to intercept strings in PHP, and you can also use PHP functions directly in thinkphp. This article will briefly introduce the specific usage of intercepting strings in thinkPHP templates. I hope it will be helpful to you.
For English characters you can use the following form:
If it is Chinese character thinkphp provides msubstr, the usage is as follows:
The msubstr function is described as follows:
msubstr($str, $start=0, $length, $charset=”utf-8″, $suffix=true)
$str: to intercept String
$start=0: starting position, default starts from 0
$length: interception length
$charset=”utf-8″: character encoding, default UTF-8
$suffix =true: Whether to display an ellipsis after the intercepted character. The default is true to display, false to not display