I am trying to reference something inside an array i get from a function.
Lets say I have a collection named $myArrays
and when i call $myArrays->first();
I will get an array.
Now when I try to get the first element in my array with $myArrays->first()[0]
this doesn't work. Why is that so and is there a way to use it in a similar way?
Regards, Senad
Because you are not using PHP 5.4:
Function array dereferencing has been added, e.g. foo()[0]
You need a temporary variable:
$first = $myArrays->first();
$first[0]
And no, you cannot "trick" PHP this way either:
($myArray->first())[0]