note 41447 added to language.variables
| From: | php-general at lists dot php dot net | Date: | Sat, 10 Apr 2004 07:52:40 +0000 |
| Subject: | note 41447 added to language.variables | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-67947@lists.php.net to get a copy of this message | ||
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. :)
----
Manual Page -- http://www.php.net/manual/en/language.variables.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+41447
Delete -- http://master.php.net/manage/user-notes.php?action=delete+41447&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+41447&report=yes
Search -- http://master.php.net/manage/user-notes.php