title: Php how to replace string range dynamically with preg_replace?
body: <p>I want to replace range of characters dynamically using preg_replace. e.g. D01 to D99 i want to replace this string range with blank and M01 to M99 want to replace it with <code>&lt;br/&gt;</code> tag. I am trying to replace it using array of static values. This is my code.</p>
  
  <pre><code>$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("","","","","&lt;br/&gt;","&lt;br/&gt;","&lt;br/&gt;");
  echo str_replace($str_arr1,$replace_arr2,$str2);
  </code></pre>