Re: Kill Magic Quotes

From: Date: Fri, 08 Aug 2008 14:34:39 +0000
Subject: Re: Kill Magic Quotes
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-277898@lists.php.net to get a copy of this message
Dave M G wrote:
PHP List, I found this solution after a web search. I can't attribute the author, but would like to if I could.
I have a routine like this: if (isset($_POST['choice'])) { if (get_magic_quotes_gpc() ){ stripslashes_arrays( $_POST ); } $choice = $_POST['choice']; } else { $choice = 'unknown'; } and this is the function # strips slashes to a multi dimensional array, by reference function stripslashes_arrays(&$array) { if ( is_array($array) ) { $keys = array_keys($array); foreach ( $keys as $key ) {
    if ( is_array($array[$key]) ) {
      stripslashes_arrays($array[$key]);
    }
    else {
      $array[$key] = stripslashes($array[$key]);
    }
} } }

« previous php.general (#277898) next »