NYCPHP Meetup

NYPHP.org

[nycphp-talk] Access an element of a method that returns an array

Adam Maccabee Trachtenberg adam at trachtenberg.com
Tue Jul 20 18:35:31 EDT 2004


On Tue, 20 Jul 2004, Fan, Wellington wrote:

> I have an instance method that returns an array. I want to access one piece
> of the array and have tried these, only to get *parse errors*:
>
> echo $myObject->littlePieces()[3];
> echo ($myObject->littlePieces())[3];

Is this PHP 4 or PHP 5. I'm not surprised if it doesn't work in PHP
4. I think that should work in PHP 5, but I wouldn't swear to it.

-adam

-- 
adam at trachtenberg.com
author of o'reilly's "upgrading to php 5" and "php cookbook"
avoid the holiday rush, buy your copies today!



More information about the talk mailing list