d_barszczak Posted June 13, 2006 Share Posted June 13, 2006 I am currently designing a Flash PHP MYSQL Chatroom which will allow users to have a chatroom on their website but hosted from mine.The early beta version is availerble on my website for viewing.I would like to add a content filter option to the client that stops users from submitting certain words so i need a way of removing or detecting certain words from a variable.Once i do this i will be able to cycle through an array of words which are stored in a mysql database.All this is done but just can't seem to find the command to find the words withing the variable. Link to comment https://forums.phpfreaks.com/topic/11845-remove-swear-words-from-variable/ Share on other sites More sharing options...
joquius Posted June 13, 2006 Share Posted June 13, 2006 [code]foreach ($unallowed as $badword){preg_replace ("/$badword/", "", $text);}[/code] Link to comment https://forums.phpfreaks.com/topic/11845-remove-swear-words-from-variable/#findComment-44917 Share on other sites More sharing options...
d_barszczak Posted June 13, 2006 Author Share Posted June 13, 2006 [!--quoteo(post=383161:date=Jun 13 2006, 10:08 AM:name=joquius)--][div class=\'quotetop\']QUOTE(joquius @ Jun 13 2006, 10:08 AM) [snapback]383161[/snapback][/div][div class=\'quotemain\'][!--quotec--][code]foreach ($unallowed as $badword){preg_replace ("/$badword/", "", $text);}[/code][/quote]Thankyou i have searched for ages to find somthing to do that but i hate using forums when i have the manual sat on my desktop.Cheers joquius. [img src=\"style_emoticons/[#EMO_DIR#]/smile.gif\" style=\"vertical-align:middle\" emoid=\":smile:\" border=\"0\" alt=\"smile.gif\" /] Link to comment https://forums.phpfreaks.com/topic/11845-remove-swear-words-from-variable/#findComment-44923 Share on other sites More sharing options...
redarrow Posted June 13, 2006 Share Posted June 13, 2006 my littel example.[code]<?$bad_words=array("1" , "2" , "3");$repace_words=str_replace($bad_words, " " , " ");echo $repalce_words;?>[/code] Link to comment https://forums.phpfreaks.com/topic/11845-remove-swear-words-from-variable/#findComment-44928 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.