function returnsAnArray () { return array ('test'); } echo returnsAnArray ()[0];
generates a syntax error in PHP. What’s the most efficient way to directly obtain an element from a returned array without assigning the result to a temp variable?
Here’s one way, using the list language construct
You could grab a sequence of elements from an offset by combining this with array_slice