阅读(4610) (6)

Laravel 8 preg_replace_array() {#collection-method}

2021-07-03 15:41:04 更新

preg_replace_array 函数使用正则表达式用给定的数组替换字符串中的内容后的结果:

$string = 'The event will take place between :start and :end';

$replaced = preg_replace_array('/:[a-z_]+/', ['8:30', '9:00'], $string);

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