Re: Simple Question

From: Date: Mon, 18 Sep 2000 17:04:08 +0000
Subject: Re: Simple Question
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-17154@lists.php.net to get a copy of this message
On Mon, 18 Sep 2000, Scott Culverhouse wrote: > Follows is a simple bit of code, i want to itterate through a number of > variables called item1, item2 and item3 > > <? > $item1="Lamb"; > $item2="Furniture"; > $item3="Chair"; > > for( i=1; i<=3; i++) > { > echo("Item ".$item$i) << This does not work! > } > > So the three echo should look like:- > > echo("Item ".$item1) > echo("Item ".$item2) > echo("Item ".$item3) > Try this : for ($i = 1; $i < 4; $i++) { $variable = "item" . $i; echo "\$item$i = " . $$variable . "<br>\n"; } Regards, Joao -- Joao Prado Maia Web Developer Kefta, Inc. T: (415) 391-6881 ext 8008 F: (415) 391-7079 Marketers: Check out http://www.kefta.com for your next risk free acquisition campaign! Sign up for a Keftamail account today: the free email that pays! http://www.keftamail.com/www/reg.php

« previous php.general (#17154) next »