NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page [resolved] Filtering profanity

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

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 08-15-2007, 10:39 AM THREAD STARTER               #1 (permalink)
Senior Member
Join Date: Aug 2007
Posts: 2,172
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, 12:07 PM   #2 (permalink)
Senior Member
 
Xyzer's Avatar
Join Date: Aug 2005
Location: United Kindom
Posts: 1,502
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 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)) {
????: NamePros.com http://www.namepros.com/programming/362165-resolved-filtering-profanity.html
str_ireplace($row['badword'], $row['replacewith'], $text);
????: NamePros.com http://www.namepros.com/showthread.php?t=362165
}
}
?>
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 01:47 PM. Reason: SMALL typo
Xyzer is offline  
Closed Thread


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


Liquid Web Smart Servers  
All times are GMT -7. The time now is 03:38 AM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger