RE: [PHP] Dynamic Arrays?
| From: | John Guynn | Date: | Thu, 15 Mar 2001 14:22:21 +0000 |
| Subject: | RE: [PHP] Dynamic Arrays? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-44029@lists.php.net to get a copy of this message | ||
My first idea is something like this:
$counter=1
while ($counter <= some maximum number){
$arrayvalue="var".$counter
write $arrayname[$arrayvalue] to database
$counter++;
}
That should get the job done.
One other idea (depending on if you are just storing data or if you need to
manipulate it) is to serialize or implode the array and store the result of
the serialize/implode operation in the database.
John Guynn
This email brought to you by RFCs 821 and 1225.
-----Original Message-----
From: RealGM [mailto:webmaster@realgm.com]
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.
PLEASE can someone help??