I have a data array like
$data = [
'name' => [
(int) 0 => '095a108478345cac184f956b1e8dee91a5a89f87bbabd7b3fb4058f577adf.jpg',
(int) 1 => '02059.jpg',
(int) 2 => 'avatar.jpg'
],
'type' => [
(int) 0 => 'image/jpeg',
(int) 1 => 'image/jpeg',
(int) 2 => 'image/jpeg'
],
'tmp_name' => [
(int) 0 => 'C:\xampp\tmp\php17AA.tmp',
(int) 1 => 'C:\xampp\tmp\php17BA.tmp',
(int) 2 => 'C:\xampp\tmp\php17BB.tmp'
],
'error' => [
(int) 0 => (int) 0,
(int) 1 => (int) 0,
(int) 2 => (int) 0
],
'size' => [
(int) 0 => (int) 80542,
(int) 1 => (int) 6532,
(int) 2 => (int) 6879
]
]
And I need to convert to an array like this
$data = [
(int) 0 => [
'name' => '095a108478345cac184f956b1e8dee91a5a89f87bbabd7b3fb4058f577adf.jpg',
'type' => 'image/jpeg',
'tmp_name' => 'C:\xampp\tmp\php17AA.tmp',
'error' => (int) 0,
'size' => (int) 80542
],
(int) 1 => [
'name' => '02059.jpg',
'type' => 'image/jpeg',
'tmp_name' => 'C:\xampp\tmp\php17BA.tmp',
'error' => (int) 0,
'size' => (int) 6532
],
(int) 2 => [
'name' => 'avatar.jpg',
'type' => 'image/jpeg',
'tmp_name' => 'C:\xampp\tmp\php17BB.tmp',
'error' => (int) 0,
'size' => (int) 6879
]
]
I am looking for the right way to convert the first php array to the second. Are there any PHP array functions provided for these actions. Is this possible with CakePHP array management?
Yes, I can do a few foreach loops and create the array I need, but I'm not sure if there is a more elegant way.