Re: Variable Problem

From: Date: Sat, 19 Jan 2002 05:30:12 +0000
Subject: Re: Variable Problem
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-81196@lists.php.net to get a copy of this message
> How do I combine the following so it is treated as one variable. It's a good question, but why? Most likely an array will work best for this job, arrays are good: http://www.php.net/manual/en/language.types.array.php The man page on foreach is nice too, and has many examples which include while/list alternatives: http://www.php.net/manual/en/control-structures.foreach.php Your question was answered below but I couldn't resist throwing in a little array propaganda, jic :) Arrays work great in forms too! http://www.php.net/manual/en/faq.html.php#AEN73718 Regards, Philip Olson > > > >$i=10 > >$result$i="test"; > > > >I want this to be: > > > >$result10="test"; > > > >$i changes so I cannot just put in 10 instead of I. > >anybody know how i can do that? > > > >TIA > >Randy > > How about the below. > > <? > $i=10; > ${"result$i"}="test"; > echo $result10; > ?> > > or > > <? > $i=10; > ${'result'.$i}="test"; > echo $result10; > ?> > > Cheers :-) > ----------------------------------- > K.Tomono

« previous php.general (#81196) next »