Laravel 8 padBoth {#collection-method}
padBoth
方法包装了 PHP 的 str_pad
函数,在指定字符串的两侧填充上另一字符串:
use Illuminate\Support\Str;
$padded = Str::of('James')->padBoth(10, '_');
// '__James___'
$padded = Str::of('James')->padBoth(10);
// ' James '
padBoth
方法包装了 PHP 的 str_pad
函数,在指定字符串的两侧填充上另一字符串:
use Illuminate\Support\Str;
$padded = Str::of('James')->padBoth(10, '_');
// '__James___'
$padded = Str::of('James')->padBoth(10);
// ' James '