Untitled
by hellokakfer, 089601594100Anonymous
plain_text
03/08/2021 5:37 AM
576 B
29
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...