Possible Duplicate:
PHP syntax for dereferencing function result
If a PHP function returns an array, the following syntax will not work:
$firstValue = $object->methodThatReturnsArray()[0]; // syntax error, unexpected '['
This, however, works fine:
$temporaryArray = $object->methodThatReturnsArray();
$firstValue = $temporaryArray[0]; // temporary will never be reused
What is the best syntax to solve this problem, or is creating that variable the recommended approach?