fork download
  1. <?php
  2.  
  3. $parent = [
  4. 1 => Array (
  5. 0 => 'test1',
  6. 1 => 'test2'
  7. ),
  8. 2 => Array (
  9. 0 => 'test1_1',
  10. 1 => 'test2_2'
  11. )
  12. ];
  13.  
  14. $result = [];
  15. foreach (array_keys($parent) as $i => $k) {
  16. $result[$k] = array_column($parent, $i);
  17. }
  18.  
  19.  
  20. print_r($result);
  21.  
Success #stdin #stdout 0.02s 26524KB
stdin
Standard input is empty
stdout
Array
(
    [1] => Array
        (
            [0] => test1
            [1] => test1_1
        )

    [2] => Array
        (
            [0] => test2
            [1] => test2_2
        )

)