How to apply something to every variable
| From: | Chris Anderson | Date: | Fri, 06 Jul 2001 22:06:54 +0000 |
| Subject: | How to apply something to every variable | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-56580@lists.php.net to get a copy of this message | ||
I was playing around trying to find a way to addslashes() to all my variables, and I came up with
this snippet. Hope it helps someone
$keys = array_keys($HTTP_POST_VARS);
$post_size = sizeof($keys);
for($x = 0; $x < $post_size; $x++)
{
$temp = $keys[$x];
//you can replace addslashes with whatever you want to use
${"$temp"} = addslashes($HTTP_POST_VARS["$temp"]);
}