note 41447 deleted from language.variables by nlopess

From: Date: Sat, 10 Apr 2004 10:40:33 +0000
Subject: note 41447 deleted from language.variables by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-67951@lists.php.net to get a copy of this message
Note Submitter: ---- In adition to: risa4 at law dot leidenuniv dot nl It works, but it's kinda nasty, isn't it? <?php $numvars = 5; // number of vars, isn't even needed: $i = 1; while(isset(${'myvar' . $i})) { global ${'myvar' . $i}; $i++; // increase $i by 1, so the next var will get global too } ?> Tada, it uses a variable variable to find whether the variable exists or not and the while takes care of the number of total variables. So, you don't have to stuck around with $numvars = X; and all that stuff. :)

« previous php.notes (#67951) next »