Posted by number1.email on 12/12/05 02:45
I have an array with the following values:
$q[0] = 100;
$q[1] = 200;
$q[2] = 300;
$q[3] = 400;
If I execute the following statement:
echo $q[2];
The expected answer of 300 is displayed on the screen.
I'm trying to print out the contents of this array in a for loop,
so I'd like to be able to build up the variable using the index of the
for loop.
For example;
for($i = 0; $i < 4; $i++) {
$param3 = ${ "$q[" . $i . "]" };
echo $param3;
}
So, I would like the output of this for loop to be 100200300400 when it
has completed.
This doesn't seem to work...can anyone supply me with the right
statement (ie: $param3 = ${ "$q[" . $i . "]" }; ) that will work?
Thanks.
[Back to original message]
|