Abdul Shakoor Kakar
Abdul Shakoor Kakar

Reputation: 611

Merge php array merge without removing array key

I have arrays like this.

Array ( 
[title] => Array ( [0] => Value1 ) 
[description] => Array ( [0] => Value1 )
) 

but i want the arrays to be look like this.

Array ( [title] => Value1 [description] => Value1 ) 

Upvotes: 5

Views: 96

Answers (1)

Federkun
Federkun

Reputation: 36934

Simply

$array = array_map(function ($element) {
   return $element[0];
}, $array);

Test: http://3v4l.org/qd2eG

Upvotes: 6

Related Questions