ctcp Posted March 27, 2011 Share Posted March 27, 2011 my fanction <?php function language_filter($string) { // no matter where you get $obscenities array, from database, file or just from the script... $obscenities = array("test","word"," foul ","language"); foreach ($obscenities as $curse_word) { if (stristr(trim($string),$curse_word)) { $length = strlen($curse_word); for ($i = 1; $i <= $length; $i++) { $stars .= "*"; } $string = eregi_replace($curse_word,$stars,trim($string)); $stars = ""; } } return $string; } ?> can sombady help me what is wrong here and not work <?php echo $string = ($row_usersinfo['username']); language_filter($string);?> Link to comment https://forums.phpfreaks.com/topic/231874-faction-help/ Share on other sites More sharing options...
Skewled Posted March 27, 2011 Share Posted March 27, 2011 http://php.net/manual/en/function.eregi-replace.php Eregi was depreciated and you should look at the alternative now. As for this: <?php echo $string = ($row_usersinfo['username']); language_filter($string);?> If your wanting to filter the username for profanity then you call your function like so: <?php echo language_filter($row_usersinfo['username']);?> make sure your including the .php file that holds the function if it's outside the code your using. Link to comment https://forums.phpfreaks.com/topic/231874-faction-help/#findComment-1192937 Share on other sites More sharing options...
ctcp Posted March 27, 2011 Author Share Posted March 27, 2011 Thank you Link to comment https://forums.phpfreaks.com/topic/231874-faction-help/#findComment-1192940 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.