Laravel 8 Str::limit() {#collection-method}
Str::limit
方法将字符串以指定长度进行截断:
use Illuminate\Support\Str;
$truncated = Str::limit('The quick brown fox jumps over the lazy dog', 20);
// The quick brown fox...
您亦可通过第三个参数来改变追加到末尾的字符串:
use Illuminate\Support\Str;
$truncated = Str::limit('The quick brown fox jumps over the lazy dog', 20, ' (...)');
// The quick brown fox (...)