fork(2) download
  1. <?php
  2.  
  3. $text = 'An apple, some Apples, and a SNAPPLE. Apple! Orange!';
  4.  
  5. echo str_ireplace('apple', '<b>' . 'apple' . '</b>', $text);
  6.  
  7. echo "\n\n";
  8.  
  9. echo preg_replace("/\b(" . 'apple' . ")\b/i", "<b>$1</b>", $text);
Success #stdin #stdout 0.01s 52488KB
stdin
Standard input is empty
stdout
An <b>apple</b>, some <b>apple</b>s, and a SN<b>apple</b>. <b>apple</b>! Orange!

An <b>apple</b>, some Apples, and a SNAPPLE. <b>Apple</b>! Orange!