fork download
  1. <?php
  2.  
  3. $str = "this is isolated is an example of this and that";
  4. $testArray = array('is','isolated','somethingElse');
  5. foreach($testArray as $tag){
  6. $str = preg_replace("~\b(?<!#)".$tag."~i","#\$0",$str);
  7. }
  8. echo $str;
Success #stdin #stdout 0.02s 52488KB
stdin
Standard input is empty
stdout
this #is #isolated #is an  example of this and that