public static function truncateWords($str, $length, $trailing='...') {
		$words = explode(' ', $str);
		$cutwords = array_slice($words, 0, $length);

		return implode(' ', $cutwords).(count($words) > count($cutwords) ? $trailing:'');
	}
public static function truncateWords($str, $length, $trailing='...') {
		$words = explode(' ', $str);
		$cutwords = array_slice($words, 0, $length);

		return implode(' ', $cutwords).(count($words) > count($cutwords) ? $trailing:'');
	}
public static function truncateWords ( $ str , $ length , $ trailing = '...' ) { $ words = explode ( ' ' , $ str ) ; $ cutwords = array_slice ( $ words , 0 , $ length ) ; return implode ( ' ' , $ cutwords ) . ( count ( $ words ) > count ( $ cutwords ) ? $ trailing : '' ) ; }
Truncate a string by words.
@param  string  $str
@param  integer $length
@param  string $trailing
@return string
@api
Truncate a string by words .