Re: For Loop
| From: | D. Dante Lorenso | Date: | Wed, 21 Jun 2006 00:13:30 +0000 |
| Subject: | Re: For Loop | ||
| References: | 1 2 3 4 5 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-238441@lists.php.net to get a copy of this message | ||
Albert Padley wrote:
Thanks everyone. Always nice to know there is more than one direction to go in.A alternative to variable variables might use these: http://us3.php.net/manual/en/function.compact.php http://us3.php.net/manual/en/function.extract.php 'extract' looks like it might be right up your alley: <?php $vars = array(); for ($i=1; $i<100; $i++) { $vars["p".$i."name"] = $i; } extract($vars); ?> Dante
On Tuesday 20 June 2006 15:14, Albert Padley wrote:I have a regular for loop - for($i=1; $i<100; $i++) Within the loop I need to create variables named: $p1name; $p2name; $p3name; etc. The integer portion of each variable name needs to be the value of $i. I can't seem to get my syntax correct? Can someone point me in the right direction? Thanks. Albert Padley