Badwords are bad, how can i get rid of them?
Moderator: General Moderators
-
chris12295
- Forum Contributor
- Posts: 113
- Joined: Sun Jun 09, 2002 10:28 pm
- Location: USA
- Contact:
Badwords are bad, how can i get rid of them?
i have a database table of bad words, how can i find all occurences of the words in a form text field and replace them with a blank?
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
If you put all the bad words into an array you can use str_replace() to change any occurances to blanks:
Outputs
Mac
Code: Select all
$badwords = array('foo', 'bar', 'ick');
$my_dirty_text = 'This is a foo bar ick day';
$my_clean_text = str_replace($badwords, '', $my_dirty_text);
echo $my_clean_text;Code: Select all
This is a day