title: Check if string contains spam words
body: <p>Am trying to implement a little bit of code found on stack overflow which covers a spam words filter. When i just type a spam word the function works however when I type in a bunch of text before the spam word it passes. I've checked the source and I must be missing something, can anyone help?</p>
  
  <p>code is:</p>
  
  <pre><code>function strpos_arr($haystack, $needle) {
      if(!is_array($needle)) $needle = array($needle);
      foreach($needle as $what) {
      if(($pos = strpos($haystack, $what))!==false) return $pos;
  }
  return false;
  }
  </code></pre>
  
  <p>function I'm calling it like is:</p>
  
  <pre><code>if(strpos_arr($text, $bad_words)) {
          return false;
      } else {
          return true;
      }
  </code></pre>
  
  <p>the array is just a simple array with a lot of bad words like so:</p>
  
  <pre><code>$bad_words = array(
          'bad word 1',
          'bad word 2');
  </code></pre>
  
  <p>link to original article: <a href="https://stackoverflow.com/questions/6284553/using-an-array-as-needles-in-strpos">Using an array as needles in strpos</a></p>
  
  <p>Thanks</p>