title: Detecting prohibited words within a string
body: <p>I have a function for checking bad words but it doesn't work how I want it to. For example test was a cuss word then if i said "testing" the function would count it as a cuss word. How would  i fix this so that it doesn't do that.</p>
  
  <p>here is my code:</p>
  
  <pre><code>    function censor($message) {
          $badwords = $this-&gt;censor; //array with the cuss words.
          $message = @ereg_replace('[^A-Za-z0-9 ]','',strtolower(' '.$message.' '));
          foreach($badwords as $bad) {
              $bad = trim($bad);
              if(strpos($message.' ', $bad.' ')!==false) {
                  if(strlen($bad)&gt;=2) {
                      return true;
                  }
              }
          }
      }
  </code></pre>