On 6/15/07, Chris <christian@xxxxxxxxx> wrote:
""kvigor"" <k3cheese@xxxxxxxxxxxxx> schrieb im Newsbeitrag news:F1.A3.42977.060A2764@xxxxxxxxxxxxxxx > Hello, > > I 'm checking form data for profanity but it only works if the > $_POST['var'] is lowercase I was wondering if anyone knew how I could > catch the profanity no matter what case it was. No matter if it was BAD or > bad or mixed like BaD? > > Instead of the long way: > > if ($value == "fuck" || $value == "shit" || $value == "whore" || $value == > "shit" || $value == "bullshit" || $value == "ass" || $value == "asshole" > || $value == "piss" || $value == "bitch" || $value == "bastard" || $value > == "motherfucker" || $value == "pussy" || $value == "cunt" || $value == > "slut" || $value == "hell" || $value == "goddamn" || $value == "skank" || > $value == "Tit" || $value == "dick" || $value == "hoe") > { > $profanity[$field] = "bad"; > } > > Any suggestions welcome. Hi Have you tried eregi()? That might work for you. Cheers Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Try this. It uses str_ireplace();, which - as of PHP 4.3.3 - can accept arrays. It will also replace parts of words, so if you have shit, ShIt, BULLShIT, ShitFuckCocksuckerPissbag, et cetera (this is fun!), it will replace the offending part of the words with asterisks. HOWEVER, keep in mind that legitimate words such as pass, cockroach, peacock, or saltwater will also be filtered, so you may want to make some adjustments or concessions. As Richard always says, "your mileage may vary." <? $myarr = array('fuck','shit','piss'); $str = "This is fUckInG BULLShIT!"; $str = str_ireplace($myarr,'****',$str); echo $str."\n"; ?> -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php