Assume we have a string patterns also provide us a common vocabulary to describe solutions
.
We substr()
this string so we have patterns also provide us a common vocabulary to desc
.
How to cut last string to patterns also provide us a common vocabulary to
?
My way is:
$text = mb_substr($new['text'], 0, 100);
if(mb_substr($text, -1) != ' ') {
$text_expl = explode(' ', $text);
$text = implode(' ', array_splice($text_expl, 0, -1)) . ' ...';
}
Is there something nicer?
Maybe regualr expression or some PHP built-in function can do something similar?