How can I intercept Chinese strings in cakephp? -PHP source code

Source: Internet
Author: User
Ec (2); how can I intercept Chinese strings in the cakephp tutorial? The Text-& gt; truncate method has three parameters: $ text: string to be truncated $ length: The length to be truncated. The default value is to intercept 100 characters $ options: array parameter. Ending indicates adding the ending string at the end of the intercepted string; if the value of exact is false, the word is not truncated; if the value of html is true, the script ec (2) under the htmltag is not truncated ); script

How to intercept a Chinese string in the cakephp tutorial?


The Text-> truncate method has three parameters:

$ Text: string to be truncated
$ Length: The length to be intercepted. The default value is 100 characters.
$ Options: array parameter. Ending indicates adding the ending string to the end of the intercepted string. If the value of exact is false, the word is not truncated. If the value of html is true, the html tag is not truncated.
The following code demonstrates how to use the tuncate method:

View sourceprint? Echo $ this-> Text-> truncate (

'The killer crept forward and tripped on The rug .',

22,

Array (

'Ending' => '...',

'Delete' => false

)

);

The above code will output The killer crept...

Note: If you want to intercept Chinese strings, it is best to set exact to true. Otherwise, Chinese characters cannot be truncated.

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.