maggotondlus Posted April 26, 2006 Share Posted April 26, 2006 Hi everyone... Please help me on this one...I just finished a script that will check if a string or an array of strings contains offensive/swear words. Now my problem is how can I match a string containing spaces (i.e S H I T) with the bad word saved in my database (i.e shit)?I am having trouble with this. Can anyone help me please.. Thanks!Here's the function that I did:[code]function swear_checker($sc_string) { if (!is_array($sc_string)) return "Error: Data not an array"; $query = "SELECT table.swear_checker.sc_word FROM table.swear_checker ORDER BY table.swear_checker.sc_id"; $result = mysql_query($query) or die(mysql_error()); $rl = mysql_num_rows($result); foreach ($sc_string as $key => $value) { $arrayVal[] = $value; } while ($rs = mysql_fetch_array($result)) { foreach( $arrayVal as $key => $value) { $match = ereg_replace($rs[sc_word], "****", $value); if ($match != $value) { return false; } else { $string = $sc_string; } } } return true; }[/code] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.