Home  >  Article  >  Backend Development  >  Detailed explanation of examples of php intercepting substrings without destroying words

Detailed explanation of examples of php intercepting substrings without destroying words

黄舟
黄舟Original
2017-08-15 11:26:211580browse

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:

Detailed explanation of examples of php intercepting substrings without destroying words

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn