Page 1 of 1

PHP's preg_replace

Posted: Wed Oct 26, 2005 9:26 am
by quadoc
I've the following code that replacing every '\' with a '' in $message, but for some reasons it's giving me error. Could someone tells me what I did wrong? Thanks... :?

Code: Select all

$message = preg_replace('/\/','',$message);

Posted: Wed Oct 26, 2005 9:33 am
by feyd
your code is wasting time initializing the regex engine...

Code: Select all

$message = str_replace('\\','',$message);
You may want to look at stripslashes as well...

Posted: Wed Oct 26, 2005 9:45 am
by quadoc
Thanks feyd. :)