阅读(2339) (4)

Laravel 8 replaceArray {#collection-method}

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

replaceArray 方法按照数组顺序使用其值替换字符串的指定部分:

use IlluminateSupportStr;

$string = 'The event will take place between ? and ?';

$replaced = Str::of($string)->replaceArray('?', ['8:30', '9:00']);

// The event will take place between 8:30 and 9:00