|
Posted by Rik on 06/15/07 20:03
On Fri, 15 Jun 2007 21:19:50 +0200, Ciaran <cronoklee@hotmail.com> wrote=
:
> Can someone please give me a hand with this?
>
> $arr=3Darray(2,4,5,6);
>
> $test=3D'arr';
>
> echo (eval("$".$test."[0]"));
>
> I'm trying to get it to echo 2
Eval doesn't return anything if you don't tell it to. You could use a =
return though (the same as in function/methods/included files).
So, to echo it, you could use: echo eval('return $'.$test.'[0]');
The curly braces method as described by others is preferable though.
-- =
Rik Wasmus
Navigation:
[Reply to this message]
|