Articles

Crop text without splitting words

An example of some code that crops text without stopping part way through a word.

$description = $crop_desc ?
implode(" ", array_slice (explode(" ", $details->Description),0, $crop_desc)).'...'.$morelink
: $details->Description;