The reason for this behavior is that PHP functions can't be chained like JavaScript functions can be. Just like document.getElementsByTagNames('a')[0]
is possible.
You have to stick to the second approach for PHP version < 5.4
Function array dereferencing has been added, e.g. foo()[0].
http://php.net/manual/en/migration54.new-features.php