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: