Reply to Re: help with eval usage

Your name:

Reply:


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

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация