Jump to content

Archived

This topic is now archived and is closed to further replies.

d_barszczak

Remove Swear Words From Variable

Recommended Posts

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.

Share this post


Link to post
Share on other sites
[code]
foreach ($unallowed as $badword)
{
preg_replace ("/$badword/", "", $text);
}
[/code]

Share this post


Link to post
Share on other sites
[!--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\" /]

Share this post


Link to post
Share on other sites

my littel example.
[code]
<?

$bad_words=array("1" , "2" , "3");

$repace_words=str_replace($bad_words, " " , " ");

echo $repalce_words;

?>
[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.