You are here: Re: directly using an index on returned array « PHP Programming Language « IT news, forums, messages
Re: directly using an index on returned array

Posted by JHN on 01/17/07 14:51

Just out of curiosity why would you not want to use something like


function giveArr($n){
array("one","two","three");
return array[$n];
}

echo giveArr(1);

Don't know of any other way, but I'm not a pro...

-Johan


Erwin Moller wrote:
> Hi,
>
> Consider the following code:
>
> -------------------------
> function giveArr(){
> return array("one","two","three");
> }
>
> echo giveArr()[1];
> // I am hoping for "two"
> -------------------------
>
> This syntax clearly doesn't work.
> Does anybody know if that is possible?
> If so, what is the right syntax?
>
> (Of course I can store the returned array in some variable, and then use an
> indexing on that variable.)
>
> I am curious if the above construct is possible (in another syntax
> obviously) with PHP.
>
> TIA
>
> Regards,
> Erwin Moller
>

 

Navigation:

[Reply to this 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

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