1

Possible Duplicate:
PHP syntax for dereferencing function result

The use of $tmp below is pretty ugly. Is there a way to avoid it?

function test()
{
  return array('a'=>1, 'b'=>2);
}

$tmp = test();
echo "This should be 2: ", $tmp['b'], "\n";

Is there some reason the natural

test()['b']

doesn't work?

Community
  • 1
  • 1
dreeves
  • 26,430
  • 45
  • 154
  • 229

0 Answers0