Baowaly ― /** * trim a string with a specified length containing full words * @param mixed $text * @param mixed $length * @return string */ function trim_text($text, $length) { if (strlen($text)<=$length) { return $text; } if (preg_match("-^(.*)[W][w]*$-", substr($text, 0, $length+1), $res)) { [...]
What would you say?
Be the first to comment on this blog post! Sign in or Create an account.