php 剪切文字 Posted 2021-05-05 tags: 篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php 剪切文字相关的知识,希望对你有一定的参考价值。 function cutText($text, $num = 20) { $text = trim(strip_tags($text)); if ($text) { $arr_text = explode(" ", $text); $arr_text_new = array(); if (count($arr_text) > $num) { for ($i=0; $i < $num; $i++) { $arr_text_new[$i] = $arr_text[$i]; } $text = implode(" ", $arr_text_new); } } return $text; } 以上是关于php 剪切文字的主要内容,如果未能解决你的问题,请参考以下文章