title: Replacing a word with nothing when that word is or isn't by itself with str_replace
body: <p>I'm trying to replace a certain word in my string with nothing, but I came across a problem. If that certain word is next to itself, it doesn't replace. How do I fix this? Thanks.     </p>
  
  <pre><code>$text1 = "text replace text replace text";
  $text1 = str_replace(" replace "," ",$text1);
  
  $text2 = "text replace replace text";
  $text2 = str_replace(" replace "," ",$text2);
  
  echo $text1;
  echo $text2;
  </code></pre>
  
  <p><b> Actual Results </b></p>
  
  <pre><code>text text text
  text replace text
  </code></pre>
  
  <p><b> Expected Results </b></p>
  
  <pre><code>text text text
  text text
  </code></pre>
  
  <p>P.S: I also don't want to do something like str_replace("replace"," ",$text2), with the spaces to the left and right of "replace" taken off, because what if that word is part of another word? Then it'll replace it anyway, and it'll be wrong.</p>