Skip to main content
added 88 characters in body
Source Link
Alex Howansky
  • 1.2k
  • 8
  • 13

Directly dereference arrays returned from functions.

E.g., instead of this:

$a = foo();
echo $a[$n];

You can do:

echo foo()[$n];

This works with methods too:

echo $obj->foo()[$n];

You can also directly dereference array declarations:

echo [1, 2, 3, 4, 5][$n];

Directly dereference arrays returned from functions.

E.g., instead of this:

$a = foo();
echo $a[$n];

You can do:

echo foo()[$n];

This works with methods too:

echo $obj->foo()[$n];

Directly dereference arrays returned from functions.

E.g., instead of this:

$a = foo();
echo $a[$n];

You can do:

echo foo()[$n];

This works with methods too:

echo $obj->foo()[$n];

You can also directly dereference array declarations:

echo [1, 2, 3, 4, 5][$n];
Source Link
Alex Howansky
  • 1.2k
  • 8
  • 13

Directly dereference arrays returned from functions.

E.g., instead of this:

$a = foo();
echo $a[$n];

You can do:

echo foo()[$n];

This works with methods too:

echo $obj->foo()[$n];