tags:

views:

99

answers:

2

I have the following array,

$myarray[0]['first_name']
$myarray[0]['last_name']

I want to turn it into:

$myarray['first_name']
$myarray['last_name']

with a simple oneliner?

+5  A: 

this?

$myarray = $myarray[0];
stereofrog
Someone please comment on this to clarify if I'm correct in the following statement: *If you save this by reference you will avoid the extra copy.*
cballou
no, there was a php array function that looked a whole lot "nicer"..
Bren G.
How can you get any nicer than that?
Greg
well $myarray = $myarray[0]; is just tacky to me..
Bren G.
If you don't like the syntax, don't use the language, Bren G. ;)
Duroth
A: 

or this?

$myarray = current($myarray);

stereofrog's solution still looks clearer though.

altermativ