Forum Moderators: coopster

Message Too Old, No Replies

ereg_replace

little error?

         

WhosAWhata

10:27 pm on Apr 8, 2004 (gmt 0)

10+ Year Member



What is wrong with this line of code?
$picture1 = ereg_replace("+","", $picture1);
it returns
Warning: ereg_replace(): REG_BADRPT in /home/user/www/www/folder/file.php on line 133

Robber

10:33 pm on Apr 8, 2004 (gmt 0)

10+ Year Member



I use preg rather than ereg, but heh, how different can it be! With preg there would be a couple of differences:
1) you'd put a delimiter around your pattern,eg /+/
2) the + is a quantifier, so it looks like it isn't actually acting on anything. To match a literal + you'd have to escape it eg "\+"

But if you just want to strip out all the +'s then you could do:
$picture1 = str_replace("+","", $picture1);

WhosAWhata

10:34 pm on Apr 8, 2004 (gmt 0)

10+ Year Member



ESCAPE IT!
i can't believe i forgot that!
thanks

Robber

11:00 pm on Apr 8, 2004 (gmt 0)

10+ Year Member



No problem, but I think if you are just getting rid of +'s using str_replace should in theory be a bit quicker, but thats only based on something I think I remember reading a while ago.