PHP 5 functioning returning an array- interaction without assignment?

Posted by Lee on Stack Overflow See other posts from Stack Overflow or by Lee
Published on 2010-03-12T09:21:20Z Indexed on 2010/03/12 9:27 UTC
Read the original article Hit count: 218

I'm wondering if this kind of thing will ever be possible in PHP (and whether it already is and I'm just missing something...)

<?php

function test() {
 return array(
  'id'=>10,
  'name'=>'John'
 );
}

echo 'Your name is: '.test()['name'];

?>

I'd really like to be able to use returned arrays directly instead of first assigning them to a var... possible?

© Stack Overflow or respective owner

Related posts about php

Related posts about php5