> -----Original Message-----
> From: RealGM [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, March 15, 2001 3:38 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP] Dynamic Arrays?
>
>
> Hi,
>
> I have a bit of a dilemma.
>
> I have a number of array attributes, eg. $arrayname["var1"],
> $arrayname["var2"], $arrayname["var2"], etc. up to 58, and I
> want to write these into the database.
>
> What I am hoping to do is create a counter that goes through
> the insert routine, updating the numerical value of "var".
> The problem is.. everything I have tried hasn't worked.
>
> I have tried things like...
>
> $counter=1;
>
> $arrayname[["var".$counter1]];
> $arrayname["var$counter1"];
>
> ...and variations thereof. Everything I have tried has failed.
How about just
foreach ($arrayname as $arrayval) {
do stuff with $arrayval
}
Or, if it's also important for you to know that you're dealing with the
value of "var1"...
foreach ($arrayname as $arraykey=>$arrayval) {
do stuff with $arraykey and $arrayval
}
---
Mark Roedel | "I know the answer! The answer lies within the
Systems Programmer | heart of all mankind! The answer is twelve?!?
LeTourneau University | I think I'm in the wrong building."
Longview, Texas, USA | -- Peppermint Patty (Charles Schultz)
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]