Will this find and replace bad words:

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
tecktalkcm0391
DevNet Resident
Posts: 1030
Joined: Fri May 26, 2006 9:25 am
Location: Florida

Will this find and replace bad words:

Post by tecktalkcm0391 »

Code: Select all

<?php
$text='I have a badword here and anabadwordhere';


 $badwords = array();
 
	$badwords[] = array(' where do you live', ' *!* ');
	$badwords[] = array(' \@\$\$ ', ' *!* ');
    $badwords[] = array(' a\$\$ ', ' *!* ');


    foreach ($badwords as $badword) {
	    $text = eregi_replace($badword[0],$badword[1],$text);
    }
    return trim($text);
}

?>
I am just checking this will this find and replace badwords, in something like
I have a badword here and anabadwordhere
if badword was a badword would it find it in both places or only the first badword?

Thanks.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Can you explain why this needed a new thread?
Post Reply