Reply to Re: function call as an array

Your name:

Reply:


Posted by Rami Elomaa on 04/25/07 05:29

news:v7idndPlgcRHArPbnZ2dnUVZ_j-dnZ2d@wightman.ca...
> Hi all,
>
> I'm after the PHP equivlent to this Perl construct:
>
> print @{[someFunctionCall()]}[0];
>
> In the above example someFunctionCall() would return an array, and we're
> printing the first item from the returned array..
>
> How do I do this in PHP ? (without first assigning the output of the
> function call to a variable)

If it indeed is the first element, then you can use reset (and for the last
element end) but there is no such functionality for returning the n'th
element.

echo reset(functioncall());

http://fi2.php.net/manual/en/function.reset.php
reset() rewinds array's internal pointer to the first element and returns
the value of the first array element, or FALSE if the array is empty.


--
Rami.Elomaa@gmail.com

"Good tea. Nice house." -- Worf

[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

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