Jump to content


Photo

Remove Swear Words From Variable


  • Please log in to reply
3 replies to this topic

#1 d_barszczak

d_barszczak
  • Members
  • PipPipPip
  • Advanced Member
  • 188 posts
  • LocationBradford - UK

Posted 13 June 2006 - 08:56 AM

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.

When all else fails - Try reading the manual.

Integrated IT Systems Ltd


#2 joquius

joquius
  • Members
  • PipPipPip
  • Advanced Member
  • 319 posts

Posted 13 June 2006 - 09:08 AM

foreach ($unallowed as $badword)
{
preg_replace ("/$badword/", "", $text);
}

z..z..z..z..z..z..z..z..

#3 d_barszczak

d_barszczak
  • Members
  • PipPipPip
  • Advanced Member
  • 188 posts
  • LocationBradford - UK

Posted 13 June 2006 - 09:17 AM

[!--quoteo(post=383161:date=Jun 13 2006, 10:08 AM:name=joquius)--][div class=\'quotetop\']QUOTE(joquius @ Jun 13 2006, 10:08 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
foreach ($unallowed as $badword)
{
preg_replace ("/$badword/", "", $text);
}
[/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\" /]

When all else fails - Try reading the manual.

Integrated IT Systems Ltd


#4 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 13 June 2006 - 09:36 AM


my littel example.
<?

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

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

echo $repalce_words;

?>

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users