|
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
Navigation:
[Reply to this message]
|