fork download
  1. <?php
  2.  
  3. $data = array
  4. (
  5. (
  6. 'imageName' => 'WNgrRdqZ',
  7. 'alt' => 'alt text'
  8. ),
  9.  
  10. (
  11. 'imageName' => 'xoPS0udB',
  12. 'alt' => 'Alt'
  13. )
  14. );
  15.  
  16.  
  17. $reduced = array_reduce($data,function($carry, $item){
  18. $carry['imageName'][] = $item['imageName'];
  19. $carry['alt'][] = $item['alt'];
  20. return $carry;
  21. },array());
  22.  
  23. print_r($reduced);
  24.  
Success #stdin #stdout 0.01s 20520KB
stdin
Standard input is empty
stdout
Array
(
    [imageName] => Array
        (
            [0] => WNgrRdqZ
            [1] => xoPS0udB
        )

    [alt] => Array
        (
            [0] => alt text
            [1] => Alt
        )

)