我想使用 preg_replace 动态替换字符范围。例如 D01 到 D99 我想用空白替换这个字符串范围,而 M01 到 M99 想用<br/>标签替换它。我正在尝试使用静态值数组替换它。这是我的代码。
$str1 = "This is mystrD01 and this is D03just for testingD02.M01Loream ipsum text1M02loream ipsum text2";
$arr1 = array("D01","D02","D03","D04","M01","M02","M03");
$replaceArr = array("","","","","<br/>","<br/>","<br/>");
echo str_replace($str_arr1,$replace_arr2,$str2);
HUWWW
POPMUISE