You are here: Re: can this be done, referrring to an array immediately « All PHP « IT news, forums, messages
Re: can this be done, referrring to an array immediately

Posted by pangea33 on 11/22/06 05:44

windandwaves wrote:
> Hi Folk
>
> If I have myfunction() {
> return array();
> }
>
> then can I write
>
> echo myfunction()[0];
>
> I tried that, and I can not, but is there a way or do I have to write
> $myvar = myfunction();
> echo $myvar[0];
>
> TIA
>
> >nicolaas

The answer is basically yes, you have to do it the long form way. When
you call myfunction() within the echo statement that's the end of it.
Using the bracketed array notation e.g.: echo myfunction()[0]; is
invalid syntax, as you have seen.

You could always echo inside of the function prior to returning the
object though.

 

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

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