Badword Seach in String or Variable

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

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

Post by tecktalkcm0391 »

awsome it works!

:D :D THANKS! :D :D
User avatar
tecktalkcm0391
DevNet Resident
Posts: 1030
Joined: Fri May 26, 2006 9:25 am
Location: Florida

Post by tecktalkcm0391 »

now another question i have this: (its different from the goal of previous codes)

Code: Select all

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


 $badwords = array();
 
	$badwords[] = array(' badword', ' *!* ');
	$badwords[] = array(' \@\$\$ ', ' *!* ');
     $badwords[] = array(' a\$\$ ', ' *!* ');



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


?>
And i get
Warning: eregi_replace() [function.eregi-replace]: REG_EPAREN in /home/Include Content/Badword.php on line 286
that. What wrong?
User avatar
aerodromoi
Forum Contributor
Posts: 230
Joined: Sun May 07, 2006 5:21 am

Post by aerodromoi »

tecktalkcm0391 wrote:now another question i have this: (its different from the goal of previous codes)

Code: Select all

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


 $badwords = array();
 
	$badwords[] = array(' badword', ' *!* ');
	$badwords[] = array(' \@\$\$ ', ' *!* ');
     $badwords[] = array(' a\$\$ ', ' *!* ');



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


?>
And i get
Warning: eregi_replace() [function.eregi-replace]: REG_EPAREN in /home/Include Content/Badword.php on line 286
that. What wrong?
It's telling you to watch out for special characters ;)

cy,
Marc
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

you arn't supplying a legitamate pattern.. and what is wrong with str_ireplace()?
User avatar
tecktalkcm0391
DevNet Resident
Posts: 1030
Joined: Fri May 26, 2006 9:25 am
Location: Florida

Post by tecktalkcm0391 »

aerodromoi wrote:
tecktalkcm0391 wrote:now another question i have this: (its different from the goal of previous codes)

Code: Select all

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


 $badwords = array();
 
	$badwords[] = array(' badword', ' *!* ');
	$badwords[] = array(' \@\$\$ ', ' *!* ');
     $badwords[] = array(' a\$\$ ', ' *!* ');



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


?>
And i get
Warning: eregi_replace() [function.eregi-replace]: REG_EPAREN in /home/Include Content/Badword.php on line 286
that. What wrong?
It's telling you to watch out for special characters ;)

cy,
Marc

What should I do then a stripslashes(); or something?

Jcart wrote:you arn't supplying a legitamate pattern.. and what is wrong with str_ireplace()?
Why isn't is a legitamate pattern... and nothing is wrong with str_ireplace now, it was giveing me an error beforfe.
User avatar
tecktalkcm0391
DevNet Resident
Posts: 1030
Joined: Fri May 26, 2006 9:25 am
Location: Florida

Post by tecktalkcm0391 »

another question, can I trim and array... would I do an array_map?
Robert Plank
Forum Contributor
Posts: 110
Joined: Sun Dec 26, 2004 9:04 pm
Contact:

Post by Robert Plank »

tecktalkcm0391 wrote:another question, can I trim and array... would I do an array_map?
Yeah,

Code: Select all

$array = array_map("trim", $array);
trims every element in $array.
Post Reply