Reply to Re: help with eval usage

Your name:

Reply:


Posted by Ciaran on 06/15/07 19:49

On Jun 15, 8:39 pm, Moot <use...@mootsoft.com> wrote:
> 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];


Oh great thanks , that works well. I'm used to the eval function in
flash actionscript and I just thought the php one would be the same.
What if I wanted to duplicate the original array?

$arr2=${$test};

??
Cheers

[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

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