Introduction to intercepting string functions in Thinkphp templates_PHP tutorial

WBOY
Release: 2016-07-13 10:24:45
Original
800 people have browsed it

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:

Copy code The code is as follows:

{$vo.title|substr=0,5}

If it is Chinese character thinkphp provides msubstr, the usage is as follows:

Copy code The code is as follows:

function msubstr($str, $start=0, $length, $charset=” utf-8″, $suffix=true)//Use as follows
{$vo.title|msubstr=5,5,'utf-8′,true}

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

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/825350.htmlTechArticleThere are many functions to intercept strings in php, and you can also use php functions directly in thinkphp. This article I will give you a brief introduction to the specific usage of intercepting strings in thinkPHP templates. I hope...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template