title: PHP replace common words from my file
body: <p>I've tried to make a tool in which you input a website and when you click the submit button it cURLS all the text.</p>
  
  <p>After all the cURLing, stripping it from tags, and counting the words. It's eventually an array named <code>$frequency</code>. If I echo it using <code>&lt;pre&gt;</code> tags it will show me everything just fine! (NOTE: I'm placing the contents in a file, <code>$homepage = file_get_contents($file);</code> and this is what I work with in my code, I don't know if this matters or not)</p>
  
  <p>However i don't really care if the word <code>or</code> is seen 200 times in a website, I only want the important words. So i have made an array with all the common words. Which is set eventually in the <code>$common_words</code> variable. But i can't seem to find a way to replace all words found in the  <code>$frequency</code>  to replace them with <code>""</code> if they are found in the <code>$common_words</code> as well. </p>
  
  <p>I've found this piece of code after some research:</p>
  
  <pre><code>$string = 'sand band or nor and where whereabouts foo';
  $wordlist = array("or", "and", "where");
  
  foreach ($wordlist as &amp;$word) {
      $word = '/\b' . preg_quote($word, '/') . '\b/';
  }
  
  $string = preg_replace($wordlist, '', $string);
  var_dump($string);
  </code></pre>
  
  <p>If I copy paste this it works fine, removing the <code>or, and, where</code> from the string.
  But replacing <code>$string</code> with <code>$frequency</code> or replacing <code>$wordlist</code> with <code>$common_words</code> will either not work or throw me an error like: <code>Delimiter must not be alphanumeric or backslash</code></p>
  
  <p>I hope i've formulated my question properly, if not. Please tell me!</p>
  
  <p>Thanks in advance</p>
  
  <p>EDIT: Alright, i've narrowed down the problem alot. First of all i forgot the <code>&amp;</code> inside the  <code>foreach ($wordlist as &amp;$word) {</code> </p>
  
  <p>But as it was counting all the words, the words it has replaced are all still counted. See those 2 screenshots to see what I mean: <a href="http://imgur.com/oqqZR3h,xHEZKRz#0" rel="nofollow">http://imgur.com/oqqZR3h,xHEZKRz#0</a></p>