I have these two arrays. I want to create an array within an array like this. How can I do this. The code is posted below. This is the image I'm sending in fileToUpload. The array I have
Array ( [fileToUpload] => Array ( [name] => KERINOX COFFEE.jpg [type] => image/jpeg [tmp_name] => /opt/lampp/temp/phpuk5Uyo [error] => 0 [size] => 2440617 ) )
The array I want
Array ( [fileToUpload] => Array ( [name] => Array ( [0] => KERINOX COFFEE.jpg ) [type] => Array ( [0] => image/jpeg ) [tmp_name] => Array ( [0] => /opt/lampp/temp/php0LlvE2 ) [error] => Array ( [0] => 0 ) [size] => Array ( [0] => 2502103 ) ) )
You can simply use
array_map
to achieve this, wrapping each element into another array: