"how to get first x chars from a string, without cutting off the last word?" Answer’s

0

You can use the wordwrap() function, then explode on newline and take the first part:

$str = wordwrap($str, 28);
$str = explode("n", $str);
$str = $str[0] . '...';
Wednesday, March 31, 2021
 
commonpike
answered 11 Months ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :