Re: PHP "preg_replace" help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux