I run into a special situation that needs to make
$arr = Foo::bar();
$v = $arr[$i]
into one line of code. $v = Foo::bar()[$i]
is not working.
That's not possible with PHP at the minute, although I do believe it's being added for the next PHP version. Here's some more information on the subject:
http://schlueters.de/blog/archives/138-Features-in-PHP-trunk-Array-dereferencing.html
I can't wait for this to be added too.
Array derefencing is not yet implemented in the current versions of PHP. You'll have to wait until PHP 5.4 or 6.0 are released.
How's this? Exactly what you wanted? =P
$v = Foo::barElement(0);
and...
class Foo
{
public static function barElement($index) {$t = self::bar(); return $t[$index];}
public static function bar......
}
$v = reset(Foo::bar());