How does php intercept the replacement string according to the number of words
This article mainly explains "php how to intercept the replacement string according to the number of words", the content of the explanation in the article is simple and clear, easy to learn and understand, now please follow the editor's train of thought slowly in depth, together to study and learn "php how to intercept replacement string according to the number of words" bar!
1. Use the "function substr_format () {...}" method to intercept and replace.
2. Use the "function cut_string ($str, $len) {...}" method to intercept and replace.
Example
Function cut_string ($str, $len) {/ / check length if (mb_strwidth ($str, 'UTF-8') 127? 2: 1 * if ($tlen + $chrLen > $len) break;$tstr. = $chr;$tlen + = $chrLen;$i + +;} if ($tstr! = $str) {$tstr. ='...';} return $tstr } Thank you for reading, the above is the content of "how php intercepts the replacement string according to the number of words". After the study of this article, I believe you have a deeper understanding of how php intercepts the replacement string according to the number of words, and the specific use still needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!