阅读(3518) (6)

Laravel 8 trim {#collection-method}

2021-07-05 09:43:54 更新

trim 方法用于移除字符串两端的指定字符:

use Illuminate\Support\Str;

$string = Str::of('  Laravel  ')->trim();

// 'Laravel'

$string = Str::of('/Laravel/')->trim('/');

// 'Laravel'