Unstoppable Domains

[Resolved] Filtering profanity

Spacemail by SpaceshipSpacemail by Spaceship
Watch

jido

VIP Member
Impact
61
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?
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
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:
<?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:
<?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:
0
•••
Appraise.net

We're social

Unstoppable Domains
Domain Recover
DomainEasy — Live Options
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back