Search

Laravel String Helper Function: words

November 16, 2016 —John Koster

The words helper method is similar to the limit function, but instead of limiting the number of characters returned, it limits the number of words returned.

The signature for the words helper function is:

words($value, $words = 100, $end = '...')

1use Illuminate\Support\Str;
2 
3// Hello everyone...
4echo Str::words('Hello everyone out there!', '2);