Is there anyway to unset every variable except one or two.
eg. if someone typed ?var=value&var2=value&username=Fred
Is there a way to leave var and var2 set, but remove all other variables?!
Thanks,
Danny
Is there anyway to unset every variable except one or two.
eg. if someone typed ?var=value&var2=value&username=Fred
Is there a way to leave var and var2 set, but remove all other variables?!
Thanks,
Danny
you could loop through $GLOBALS or $HTTP_POST_VARS array and unset every var except some:
<pre>
reset($GLOBALS);
do{
$name=key($GLOBALS);
if ($name!=$somevar)
{
unset($GLOBALS[$name]);
}
} while (false!=next($GLOBALS));
</pre>
Thanks, that should work...
Although would they be in $HTTP_POST_VARS? If you append ?var=value to a script isn't that the same as a GET not a POST?!
Danny
my mistake, sorry.
Yes they would be added to $HTTP_GET_VARS. i thought the vars are being send from a form.
Actually it's a good thing you pointed that out. I'd have to do both, incase someone POST variables at my script from a form!
Danny