Re: PHP "preg_replace" help
| From: | Jim Lucas | Date: | Mon, 17 Sep 2007 18:00:34 +0000 |
| Subject: | Re: PHP "preg_replace" help | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-262173@lists.php.net to get a copy of this message | ||
Chaim Chaikin wrote:
Hello, I am a beginner in PHP. I need help with the function preg_replace. I am trying to remove the backslashes ( \ ) from a string that is submitted by the user. It is submitted in a form but it adds \ before the quotation marks ( " ). Will this change if I use the GET method instead of POST. If not can you please tell me how to use preg_replace to remove the backslashes. Don't, use stripslashes() instead.http://us.php.net/stripslashes Here is a nice little hack that I use. <plaintext><?php print_r($_REQUEST); function stripInput(&$ar) { $ar = stripslashes($ar); } if ( get_magic_quotes_gpc() ) { array_walk_recursive($_REQUEST, 'stripInput'); array_walk_recursive($_POST, 'stripInput'); array_walk_recursive($_GET, 'stripInput'); } print_r($_REQUEST); ?> you should see the difference -- Jim Lucas "Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them." Twelfth Night, Act II, Scene V by William Shakespeare