NYCPHP Meetup

NYPHP.org

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

Fan, Wellington wfan at VillageVoice.com
Tue Jul 20 18:28:41 EDT 2004


Hello Listies,

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];


What gives? if I assign to a temp variable first, it works:

$tmp = $myObject->littlePieces();
echo $tmp[3];

TIA!

--
Wellington




More information about the talk mailing list