我有一个字符串数组,我想在文本中插入。
$text "some text";
foreach ($arrayStrings as $string){
$new_text = preg_replace($old_string, $new_string, $text);
}
我如何设置它,以便每次迭代将使用$new_text的前一个结果?也就是说,在结束时,我得到一个文本版本,其中包括所有新的字符串从数组,而不仅仅是最后一个,这是我现在得到的。
谢谢
我会:
$text "some text";
$new_text = $text;
foreach ($arrayStrings as $string){
$new_text = preg_replace($old_string, $new_string, $new_text);
}