note 75072 deleted from function.stripslashes by nlopess

From: Date: Sat, 12 May 2007 11:21:16 +0000
Subject: note 75072 deleted from function.stripslashes by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-126430@lists.php.net to get a copy of this message
Note Submitter: fuzzywoodlandcreatureATgmailDOTcom ---- I wrote a recursive stripslashes() that uses references so as to use as little extra RAM as possible, even on large amounts of data. It's extremely useful for annihilating magic_quotes where a simple 'please' won't do the trick. <?php /** * Created specifically for wiping out magic_quotes but probably has uses for other things too * @param mixed $input A reference to a string or array * @return void Modifies the parameter supplied */ function stripslashes_recurse(&$input) { if(is_array($input)) { foreach($input as &$element) { $this->stripslashes_recurse(&$element); } } elseif(is_string($input)&&!empty($input)) { $input=stripslashes($input); } } ?> Example usage: <?php stripslashes_recurse(&$_GET); ?>

« previous php.notes (#126430) next »