How to intercept string by word in php_PHP tutorial

WBOY
Release: 2016-07-13 09:57:45
Original
944 people have browsed it

php 按电影截取电影的设计

codes are as follows:

function limit_words($string, $word_limit)
{
$words = explode(" ",$string);
return implode(" ",array_splice($words,0,$word_limit));
}
//Example Usage
$content = "The truth is that the pain itself is important, it is followed by a gain, but at the same time it happens that there is a great deal of work and pain. For I will come to the bottom of it, no one should practice any kind of work unless he derives some benefit from it. he wants to be in pleasure, let him flee from pain, and let him not be born. Except those who are blinded by desire, they do not come out, they are in fault, who forsake the duties, that is, the soul is softened.";
echo limit_words($content,20);
?>

http://www.bkjia.com/PHPjc/980114.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/980114.htmlTechArticlephp 按电视截トリープージョード Here is the specified character string and the word's quantity are carried out 截取 CODE: ?php function limit_words ($string, $word_limit) { $words = explode( ,$string); r...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template