tibberous Posted January 4, 2011 Share Posted January 4, 2011 $keys = array(); foreach($GLOBALS as $k => $v){ $keys[] = $k; } for($t=1;$keys[$t];$t++){ unset($$keys[$t]); } unset($k); unset($v); unset($t); Yup - un-fucking-set. Hopefully Google spiders this and makes it the top result, because I spent forever looking and couldn't find this - had to figure it our myself =/ And in case your wonder why you'd ever need this - I'm using it for a template system, to wipe out all of the variables defined before the templates index file gets included. Quote Link to comment Share on other sites More sharing options...
trq Posted January 4, 2011 Share Posted January 4, 2011 Absolute genius, that will come in handy. Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted January 4, 2011 Share Posted January 4, 2011 unset($k, $v, $t); Quote Link to comment Share on other sites More sharing options...
tibberous Posted January 5, 2011 Author Share Posted January 5, 2011 unset($k, $v, $t); I was wondering what new thing I was going to learn today. Quote Link to comment Share on other sites More sharing options...
DavidAM Posted January 5, 2011 Share Posted January 5, 2011 I can write that code in two lines ... foreach (array_keys($GLOBALS) as $k) unset($$k); unset($k); of course, you realize that $GLOBALS is now gone, and you can't really get it back. And so is $_GET, $_POST, $_SERVER, etc., etc., ... Hell, I'm not really sure I'm still here! Quote Link to comment Share on other sites More sharing options...
JonnoTheDev Posted January 5, 2011 Share Posted January 5, 2011 Absolute genius, that will come in handy. LOL Quote Link to comment Share on other sites More sharing options...
trq Posted January 5, 2011 Share Posted January 5, 2011 Absolute genius, that will come in handy. LOL Finally. Quote Link to comment Share on other sites More sharing options...
Anti-Moronic Posted January 9, 2011 Share Posted January 9, 2011 Absolute genius, that will come in handy. LOL Finally. hahahahaha classic. Pikachu you have such a serious face, it's hard to tell. Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted January 9, 2011 Share Posted January 9, 2011 I didn't say anything . . . Quote Link to comment Share on other sites More sharing options...
Anti-Moronic Posted January 9, 2011 Share Posted January 9, 2011 I didn't say anything . . . Sorry, I meant you and thorpe have the same face...I am always getting confused behind the scenes :S Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.