In PHP, there are a lot of functions to intercept strings, and in thinkphp can also be directly used in PHP functions, this article gives you a simple introduction to the thinkphp template to intercept the specific use of strings, I hope to be helpful to you.
You can use the following form for English characters:
Copy the Code code as follows:
{$vo. title|substr=0,5}
If it is a Chinese character thinkphp provides msubstr, use the following:
Copy the Code code as follows:
function Msubstr ($str, $start =0, $length, $charset = "Utf-8″, $suffix =true)//Use the following
{$vo. title|msubstr=5,5, ' utf-8′,true}
Where the MSUBSTR function is described below:
Msubstr ($str, $start =0, $length, $charset = "Utf-8″, $suffix =true)
$STR: the string to intercept
$start = 0: Start position, starting from 0 by default
$length: Intercept length
$charset = "Utf-8″: Character encoding, default UTF-8
$suffix =true: If an ellipsis is displayed after the truncated character, the default is true to show that false is not displayed
http://www.bkjia.com/PHPjc/825350.html www.bkjia.com true http://www.bkjia.com/PHPjc/825350.html techarticle in PHP, there are many functions to intercept strings, and in thinkphp can also be directly used in PHP functions, this article gives you a simple introduction to the thinkphp template to intercept the specific use of strings, I hope ...