Untitled
by hellokakfer, 089601594100unknown
plain_text
4 years ago
431 B
7
Indexable
function cutWords($string, $wordsreturned) { $retval = $string; $string = preg_replace('/(?<=\S,)(?=\S)/', ' ', $string); $string = str_replace("\n", " ", $string); $array = explode(" ", $string); if (count($array) <= $wordsreturned) { $retval = $string; } else { array_splice($array, $wordsreturned); $retval = implode(" ", $array) . " ..."; } return $retval; }
Editor is loading...