|
Posted by Moot on 06/15/07 19:39
On Jun 15, 3:19 pm, Ciaran <cronok...@hotmail.com> wrote:
> Can someone please give me a hand with this?
>
> $arr=array(2,4,5,6);
>
> $test='arr';
>
> echo (eval("$".$test."[0]"));
>
> I'm trying to get it to echo 2
>
> Thanks a lot,
> Ciarán
Try this:
eval("echo $".$test."[0];");
Don't treat eval like a function that returns a string, make sure the
entire PHP statement is passed to it (including the ;).
An alternative, that looks like what you were trying to accomplish,
but without the eval would be:
echo ${$test}[0];
Navigation:
[Reply to this message]
|