Re: variable question

From: Date: Fri, 19 Jan 2001 22:24:13 +0000
Subject: Re: variable question
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-35741@lists.php.net to get a copy of this message
Put them in an array? PHP allows for variable variables, but I'm not sure they work with classes. This works: $foo0 = 'a'; $foo1 = 'b'; $foo2 = 'c'; $foo3 = 'd'; $foo4 = 'e'; for($i = 0 ; $i < 5 ; ++$i) { $var = 'foo'.$i; echo $$var; } Try it with an object... --Joe On Fri, Jan 19, 2001 at 05:15:25PM -0500, Michael Zornek wrote: > ok so i have an object that has (among other things) the following properties: > > $vendor_data->s9 > $vendor_data->s10 > $vendor_data->s11 > $vendor_data->s12 > ... > $vendor_data->s40 > > The values are 1 or 0 > > I'd like to write a loop to say: > > for ($count=9; $count>40; $count++) { > if ($vendor_data->s(insert_number_here) == 1) { > echo something; > } > } > > any thoughts? > > Mike > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net -- Joe Stump, PHP Hacker joestump98@yahoo.com http://www.miester.org/

« previous php.general (#35741) next »