note 41448 deleted from language.variables by aidan

From: Date: Sat, 18 Sep 2004 04:44:36 +0000
Subject: note 41448 deleted from language.variables by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-76918@lists.php.net to get a copy of this message
Note Submitter: webmaster __AT__ digitalanime __DOT__ nl ---- 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 (#76918) next »