In our daily development work, we often need to intercept strings. For some strings such as Chinese and numbers, we only need to intercept the number of digits. The methods you can think of here should all be used. Use the substr function to intercept. What we need to do now is not to do this, but to intercept an English word and ensure that the word is not destroyed. Today I will show you how to implement such a function~
First we download the php required this time without destroying the word interception substring class: http://www.php.cn/xiazai/leiku/644
1: After the download is complete, unzip the php class file to the local, and then create a new php file!
2: Introduce the file into a new file and call the class:
<?php include_once "jiequzfc.php";//引入类文件 //对字符串的截取处理 echo (snippet("this is not too long to run on the column on the left, perhaps, or perhaps yes, no idea") . "<br>"); echo (snippetwop("this is not too long to run on the column on the left, perhaps, or perhaps yes, no idea") . "<br>"); echo (snippetgreedy("this is not too long to run on the column on the left, perhaps, or perhaps yes, no idea"));
3. Run this file, the running results are as follows:
The above is the detailed content of Detailed explanation of examples of php intercepting substrings without destroying words. For more information, please follow other related articles on the PHP Chinese website!