Introduction to intercepting String functions in thinkphp templates _php tutorial

Source: Internet
Author: User
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 ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.