Bren G.
Bren G.

Reputation: 161

remove key from associative array with single key

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?

Upvotes: 0

Views: 468

Answers (2)

altermativ
altermativ

Reputation: 690

Or this?

$myarray = current($myarray);

user187291's solution still looks clearer though.

Upvotes: 0

user187291
user187291

Reputation: 53940

this?

$myarray = $myarray[0];

Upvotes: 5

Related Questions