fork download
  1. <?php
  2.  
  3. $arr1 = array (
  4. 't' => array ('t1','t2','t3'),
  5. 'c' => array ('c1','c2','c3'),
  6. 'd' => array ('d1','d2','d3'),
  7. );
  8.  
  9. $arr2 = array (
  10. 'j' => array ('j1','j2','j3'),
  11. 'm' => array ('m1','m2','m3'),
  12. 'n' => array ('n1','n2','n3'),
  13. );
  14.  
  15. $res = [];
  16. foreach($arr1 as $key => $value){
  17. foreach($arr2 as $k => $v){
  18. for($i = 0 ; $i<count($v); $i++){
  19. $res[$key.'-'.$k][] = $value[$i].'-'.$v[$i];
  20. }
  21. }
  22. }
  23.  
  24. print_r($res);
Success #stdin #stdout 0.02s 52432KB
stdin
Standard input is empty
stdout
Array
(
    [t-j] => Array
        (
            [0] => t1-j1
            [1] => t2-j2
            [2] => t3-j3
        )

    [t-m] => Array
        (
            [0] => t1-m1
            [1] => t2-m2
            [2] => t3-m3
        )

    [t-n] => Array
        (
            [0] => t1-n1
            [1] => t2-n2
            [2] => t3-n3
        )

    [c-j] => Array
        (
            [0] => c1-j1
            [1] => c2-j2
            [2] => c3-j3
        )

    [c-m] => Array
        (
            [0] => c1-m1
            [1] => c2-m2
            [2] => c3-m3
        )

    [c-n] => Array
        (
            [0] => c1-n1
            [1] => c2-n2
            [2] => c3-n3
        )

    [d-j] => Array
        (
            [0] => d1-j1
            [1] => d2-j2
            [2] => d3-j3
        )

    [d-m] => Array
        (
            [0] => d1-m1
            [1] => d2-m2
            [2] => d3-m3
        )

    [d-n] => Array
        (
            [0] => d1-n1
            [1] => d2-n2
            [2] => d3-n3
        )

)