I have an array of arrays, with the following structure :
array(array(\'page\' => \'page1\', \'name\' => \'pagename1\')
array(\'page\' => \'pa
I wanted to post here, even if this is an old question, because it is still very relevant and many developers do not use PHP >= 5.5
Let's say you have an array like this:
Array
(
[files] => Array
(
[name] => Array
(
[0] => file 1
[1] => file 2
[2] => file 3
)
[size] => Array
(
[0] => 1
[1] => 2
[2] => 3
)
[error] => Array
(
[0] => abc
[1] => def
[2] => ghi
)
)
)
and the output you want is something like this:
Array
(
[0] => Array
(
[0] => file 1
[1] => 1
[2] => abc
)
[1] => Array
(
[0] => file 2
[1] => 2
[2] => def
)
[2] => Array
(
[0] => file 3
[1] => 3
[2] => ghi
)
)
You can simply use the array_map() method without a function name passed as the first parameter, like so:
array_map(null, $a['files']['name'], $a['files']['size'], $a['files']['error']);
Unfortunately you cannot map the keys if passing more than one array.