PHP does not break the example of a word intercept substring

Source: Internet
Author: User
In our daily development work, many times we need to intercept the string, for Chinese, numbers and other strings, we intercept all just need to intercept the number of bits to be able to, here we think of the method should use the SUBSTR function to intercept, now what we have to do is not so, It is necessary to intercept an English word, and to ensure that the word is not destroyed, today we will give you how to achieve such a function ~


First we download the required PHP does not break the word truncation substring class: http://www.php.cn/xiazai/leiku/644


One: After the download is complete, unzip the PHP class file to local, then create a new PHP file!

Second: Introduce the file in the new file, call the class:

<?phpinclude_once "jiequzfc.php";//the Introduction of class files//Interception of Strings Echo (snippet ("This was not too long-run on the , perhaps, or perhaps yes, no idea "). "<br>"); Echo (Snippetwop ("This isn't too long to run on the ' left ', perhaps, or perhaps yes, no idea") . "<br>"), Echo (Snippetgreedy ("This was not too long-run on the ' left ', perhaps, or perhaps yes, no idea "));

Third, run the file, the results are as follows:

Related Article

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.