[advanced search]
 

Go Back   NamePros.com > Discussion > Web Design & Development > Programming

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.


Closed Thread
 
LinkBack Thread Tools
Old 08-15-2007, 09:39 AM   #1 (permalink)
Senior Member
 
Join Date: Aug 2007
Posts: 2,167
457.00 NP$ (Donate)

jido has a reputation beyond reputejido has a reputation beyond reputejido has a reputation beyond reputejido has a reputation beyond reputejido has a reputation beyond reputejido has a reputation beyond reputejido has a reputation beyond reputejido has a reputation beyond reputejido has a reputation beyond reputejido has a reputation beyond reputejido has a reputation beyond repute


Help! Filtering profanity

Hello, I am looking for a good php solution to filter out swear words in existing text. The text needs to be displayed edited.

Do you know any?
jido is offline  
Old 08-15-2007, 11:07 AM   #2 (permalink)
Senior Member
 
Xyzer's Avatar
 
Join Date: Aug 2005
Location: United Kindom
Posts: 1,506
90.70 NP$ (Donate)

Xyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to all

Tsunami Relief AIDS/HIV
If you are getting it out out a db, Make a function called profanityFilter($text) { } and then inside it, do a foreach($text as $value) { } and then get from a db like while($row=mysql_fetch_array($query)) { } and inside that do: str_ireplace($row['badword'], $row['replacewith'], $value); Then it will be done.. An example is shown below:
PHP Code:
<?php
// profanity filter
public function profanityFilter($text) {
$query = mysql_query("SELECT * FROM `wordfilter`")or die(mysql_error());
while(
$row = mysql_fetch_array($query)) {
str_ireplace($row['badword'], $row['replacewith'], $text);
}
}
?>
That may not be exactly right.. but it will get you on the right tracks.


Edit, Another way:
PHP Code:
<?php
function filter($text) {
$badwords = array('one' => '***', 'two' => '***', 'three' => '*****');
str_ireplace($badwords[0], $badwords[1], $text);}
}
?>
Second method doesn't use a db.. It's not as dynamic really..
If this helped you, Please leave rep, Thanks

Last edited by localhost; 08-15-2007 at 12:47 PM. Reason: SMALL typo
Xyzer is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Site Sponsors
Advertise your business at NamePros

All times are GMT -7. The time now is 04:26 AM.


Powered by: vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0
Template-Modifications by TMS
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85