阅读(481)
赞(7)
Laravel 8 Str::limit() {#collection-method}
2021-07-03 16:54:19 更新
Str::limit
方法将字符串以指定长度进行截断:
use IlluminateSupportStr;
$truncated = Str::limit('The quick brown fox jumps over the lazy dog', 20);
// The quick brown fox...
您亦可通过第三个参数来改变追加到末尾的字符串:
use IlluminateSupportStr;
$truncated = Str::limit('The quick brown fox jumps over the lazy dog', 20, ' (...)');
// The quick brown fox (...)