title: PHP filter bad words
body: <p>I have a filter bad words codes below
  I want to replace this ARRAY with the .txt file so that I can put all the bad words into the txt file or is there any way to use MYSQL database to store the badwords and then call from there ?    </p>
  
  <pre><code>FUNCTION BadWordFilter(&amp;$text, $replace){
  
   $bads = ARRAY (
        ARRAY("butt","b***"),
        ARRAY("poop","p***"),
        ARRAY("crap","c***")
   );
  
   IF($replace==1) {                                        //we are replacing
        $remember = $text;
  
        FOR($i=0;$i&lt;sizeof($bads);$i++) {               //go through each bad word
             $text = EREGI_REPLACE($bads[$i][0],$bads[$i][1],$text); //replace it
        }
  
        IF($remember!=$text) RETURN 1;                     //if there are any changes, return 1
  
   } ELSE {                                                  //we are just checking
  
        FOR($i=0;$i&lt;sizeof($bads);$i++) {               //go through each bad word
             IF(EREGI($bads[$i][0],$text)) RETURN 1; //if we find any, return 1
        }     
   }
  }
  
  $qtitle = BadWordFilter($wordsToFilter,1); 
  </code></pre>