[nycphp-talk] Access an element of a method that returns an ar ray
Jose Villegas
jv_nyphp at duikerbok.com
Tue Jul 20 23:09:55 EDT 2004
I thought having parentheses around an expression evaluated the
expression? If so, maybe the problem is in the syntax of the square
brackets. Maybe they will only parse correctly if they are preceded by
a variable?
jose
On Jul 20, 2004, at 9:59 PM, Joe Crawford wrote:
> i dont see this working in 4 or 5 reason being is you have to have the
> method return the array before you can actually access the elemnets so
> $obj->method()[3] will not work you must assign it to a variable before
> you can access it.
>
> i may be wrong but i think i am right, someone correct me if i am wrong
> ;)
>
> Joe Crawford Jr.
>
>
> On Tue, 2004-07-20 at 18:47, Fan, Wellington wrote:
>> Sorry; should have mentioned it's PHP 4.3.4
>>
>>>>
>>>> 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
More information about the talk
mailing list