Laravel 8 replaceFirst {#collection-method}
replaceFirst
方法用于替换字符串中指定值的第一个匹配项:
use Illuminate\Support\Str;
$replaced = Str::of('the quick brown fox jumps over the lazy dog')->replaceFirst('the', 'a');
// a quick brown fox jumps over the lazy dog
replaceFirst
方法用于替换字符串中指定值的第一个匹配项:
use Illuminate\Support\Str;
$replaced = Str::of('the quick brown fox jumps over the lazy dog')->replaceFirst('the', 'a');
// a quick brown fox jumps over the lazy dog