fork(1) download
  1. <?php
  2.  
  3. $data = array(
  4. 'A' => array(10,20,30),
  5. 'B' => array(100,200,300),
  6. 'C' => array(1000,2000,3000)
  7. );
  8.  
  9. function union($data)
  10. {
  11. $data_old = $data;
  12. $data_new = array();
  13. foreach($data_old as $key => $values)
  14. {
  15. if (is_array($values))
  16. {
  17. for($i = 0; $i < count($values); $i++)
  18. {
  19. $data_new[$i][] = array_shift($data_old[$key]);
  20. }
  21. }
  22. }
  23.  
  24. return ($data_new);
  25. }
  26.  
  27. print_r(union($data));
  28.  
Success #stdin #stdout 0.02s 23668KB
stdin
Standard input is empty
stdout
Array
(
    [0] => Array
        (
            [0] => 10
            [1] => 100
            [2] => 1000
        )

    [1] => Array
        (
            [0] => 20
            [1] => 200
            [2] => 2000
        )

    [2] => Array
        (
            [0] => 30
            [1] => 300
            [2] => 3000
        )

)