|
Posted by Oli Filth on 12/11/05 13:16
number1.email@gmail.com said the following on 11/12/2005 10:59:
> In php, I have an array called "q". The elements are:
>
> $q[0] = 2
> $q[1] = 4
> $q[2] = 5
> $q[3] = 3
>
> I'd like to be able to loop through this array via a While loop, and
> echo the contents of these array elements back to the screen.
>
> When I try something like:
>
> for($i = 0; $i < 4; $i++) {
> echo $q[i];
> echo eval("$q[i]");
> echo eval("\$q[" . i . "]");
> }
>
> I get the "String" instead of the "Contents". For example, the output
> is $q[0] instead of 2, $q[1] instead of 4, etc.
>
Use echo $q[$i].
--
Oli
Navigation:
[Reply to this message]
|