Re: changing post variable names

From: Date: Wed, 19 Sep 2001 12:23:58 +0000
Subject: Re: changing post variable names
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-67831@lists.php.net to get a copy of this message
On Wed, Sep 19, 2001 at 12:57:07PM +0100, L Melville wrote: > Hi, > > I have a php page that accepts post values (ie; > ...../page.php?var1=0&var4=5). > > Now there can be posted values between var(1) and var(10) and i want to > check if they exist and also utilise them. Is there a way of accessing > these values in a loop ie;- > > for($i=1;$i<=10;$i++){ > // do things in here that access the vars like this > $blah = $var$i; > } Something like this should work: <?php $var4 = 'Hello'; for($i=1;$i<=10;$i++){ // do things in here that access the vars like this $blah = "var$i"; if(isset($$blah)) { echo $$blah."<br>\n"; } } ?> -- Jason Stechschulte jpstech@unoh.edu -- Well, that's more-or-less what I was saying, though obviously addition is a little more cosmic than the bitwise operators. -- Larry Wall in <199709051808.LAA01780@wall.org>

« previous php.general (#67831) next »