Bad words filter if else integration
===

Is there any way to implement if else in the below mentioned badwords filter code so that when user enter any bad word it will give error "your input contains words that are not allowed" rather than replacing the badwords

    FUNCTION BadWordFilter(&$text, $replace){

    $file_array = file('/path/to/badword.txt');


    $bads = array();
    foreach ($file_array as $word_combo) {
    $bads[] = explode(',', $word_combo);
    }



    IF($replace==1) {                                        //we are replacing
      $remember = $text;

      FOR($i=0;$i<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<sizeof($bads);$i++) {               //go through each bad word
           IF(EREGI($bads[$i][0],$text)) RETURN 1; //if we find any, return 1
      }     
     }

    }

    $any = BadWordFilter($qtitle,1); 
    $any = BadWordFilter($qtitle,0); 