PHP Limit article content display word count
Http://www.3qphp.com/index/show/index/184.html
$strleng) return$str;//string length is less than the specified number of words, the return string itself $notchinanum = 0;//initial is not the character count of the kanji for ($i =0; $i < $cutleng; $i + +) {if (Ord ( substr ($str, $i, 1)) <=128) {$notchinanum + +;}} if ($cutleng%2==1) && ($notchinanum%2==0))//If you want to intercept an odd number of characters, the characters in the length range to be truncated must contain an odd number of non-Chinese characters, otherwise the length of the interception plus a {$cutleng + +;} if ($cutleng%2==0) && ($notchinanum%2==1))//If you want to intercept an even number of characters, the length of the range of characters must contain an even number of non-Chinese characters, otherwise the length of the interception plus a {$cutleng + +;} Return substr ($str, 0, $cutleng);}? >
2. Call this function when needed---cutstr
For example:
Click to view the expanded full text
The above describes the PHP limit article content display words, including aspects of the content, I hope that the PHP tutorial interested in a friend helpful.