fork download
  1. <?php
  2. $string1 = 'aaaaabbbbbcccccw**ord*';
  3. $string2 = 'word';
  4. $regexp = '#\**' . implode('\**', str_split($string2)) . '\**$#';
  5. $result = preg_replace($regexp, '', $string1);
  6. echo $result;
Success #stdin #stdout 0.01s 20520KB
stdin
Standard input is empty
stdout
aaaaabbbbbccccc