views:

54

answers:

1

In Javascript, after executing a function I can immediately get the an element of the array returned by the function, like so:

myFunc("birds")[0] //gets element zero returned from "myFunc()"

This is much easier and faster than doing this:

$myArray = myFunc("birds");
echo $myArray[0];

Does PHP have a similar shorthand to javascript? I'm just curious. Thanks in advance!

+3  A: 

No, unfortunately in PHP you can only subscript an array variable, no other kind of array returning expression.

kemp
Well, that sucks. OK, thanks!
motionman95