Programming: Trim to Full Word this is great but do you know how I would end with a full word? $the_str = substr($excerpt, 0, 20); $the_str = trim(preg_replace( '/\s+/', ' ', $the_str));