Php string truncation problems [score]

Source: Internet
Author: User
The php string truncation question [score] page obtains the title field from the database and then displays it on the front-end page. for example, the string is: & quot; php string truncation is the top, top, and top. [score] & quot; now you need to determine if you want to use "... "In place of less than 10 characters, you do not need to intercept the php string. [score question]
The page obtains the title field from the database.
Then, it is displayed on the front-end page.
For example, the string is: "The php string truncation problem is the top, the top, and the top. [score ]"

Now, we need to determine that if more than 10 characters are followed "...",
If it is less than 10 characters, you do not need...

Php string truncation...

------ Solution --------------------
PHP code
$ Title = "php string truncation issues top [score]"; $ len = mb_strlen ($ title, 'utf-8'); echo $ len> 10? Mb_substr ($ title, 'utf-8'). '...': $ title;

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.