3v4l.org

run code in 300+ PHP versions simultaneously
<?php $one = Array ( 4 => 'bim', 5 => 'pow', 6 => 'foo' ); $two = Array ( 'n' => Array ( 0 => 1 ), 'm' => Array ( 0 => 1, 1 => 2 ), 'l' => Array ( 0 => 1, 1 => 4, 2 => 64 ) ); $result = []; while((list($oneKey, $oneValue) = each($one)) && (list($twoKey, $twoValue) = each($two))) { foreach($twoValue as $item) { $result[$oneValue][]=$twoKey.'-'.$item; } }; foreach($result as $key=>$item) { $result[$key]=count($item)>1?$item:array_shift($item); } var_dump($result);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
2 jumps found. (Code = 46) Position 1 = 21, Position 2 = 29
Branch analysis from position: 21
2 jumps found. (Code = 44) Position 1 = 30, Position 2 = 4
Branch analysis from position: 30
2 jumps found. (Code = 77) Position 1 = 31, Position 2 = 45
Branch analysis from position: 31
2 jumps found. (Code = 78) Position 1 = 32, Position 2 = 45
Branch analysis from position: 32
2 jumps found. (Code = 43) Position 1 = 36, Position 2 = 38
Branch analysis from position: 36
1 jumps found. (Code = 42) Position 1 = 42
Branch analysis from position: 42
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
Branch analysis from position: 38
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
Branch analysis from position: 45
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 45
Branch analysis from position: 4
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 12
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 12
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 12
2 jumps found. (Code = 46) Position 1 = 21, Position 2 = 29
Branch analysis from position: 21
Branch analysis from position: 29
Branch analysis from position: 12
Branch analysis from position: 29
filename:       /in/COnja
function name:  (null)
number of ops:  50
compiled vars:  !0 = $one, !1 = $two, !2 = $result, !3 = $twoValue, !4 = $item, !5 = $oneValue, !6 = $twoKey, !7 = $oneKey, !8 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
    9     1        ASSIGN                                                   !1, <array>
   29     2        ASSIGN                                                   !2, <array>
   30     3      > JMP                                                      ->13
   33     4    > > FE_RESET_R                                       $12     !3, ->12
          5    > > FE_FETCH_R                                               $12, !4, ->12
   35     6    >   CONCAT                                           ~15     !6, '-'
          7        CONCAT                                           ~16     ~15, !4
          8        FETCH_DIM_W                                      $13     !2, !5
          9        ASSIGN_DIM                                               $13
         10        OP_DATA                                                  ~16
   33    11      > JMP                                                      ->5
         12    >   FE_FREE                                                  $12
   30    13    >   INIT_FCALL_BY_NAME                                       'each'
         14        SEND_VAR_EX                                              !0
         15        DO_FCALL                                      0  $17     
         16        FETCH_LIST_R                                     $18     $17, 0
         17        ASSIGN                                                   !7, $18
         18        FETCH_LIST_R                                     $20     $17, 1
         19        ASSIGN                                                   !5, $20
         20      > JMPZ_EX                                          ~22     $17, ->29
   31    21    >   INIT_FCALL_BY_NAME                                       'each'
         22        SEND_VAR_EX                                              !1
         23        DO_FCALL                                      0  $23     
         24        FETCH_LIST_R                                     $24     $23, 0
         25        ASSIGN                                                   !6, $24
         26        FETCH_LIST_R                                     $26     $23, 1
         27        ASSIGN                                                   !3, $26
         28        BOOL                                             ~22     $23
         29    > > JMPNZ                                                    ~22, ->4
   38    30    > > FE_RESET_R                                       $28     !2, ->45
         31    > > FE_FETCH_R                                       ~29     $28, !4, ->45
         32    >   ASSIGN                                                   !8, ~29
   40    33        COUNT                                            ~32     !4
         34        IS_SMALLER                                               1, ~32
         35      > JMPZ                                                     ~33, ->38
         36    >   QM_ASSIGN                                        ~34     !4
         37      > JMP                                                      ->42
         38    >   INIT_FCALL                                               'array_shift'
         39        SEND_REF                                                 !4
         40        DO_ICALL                                         $35     
         41        QM_ASSIGN                                        ~34     $35
         42    >   ASSIGN_DIM                                               !2, !8
         43        OP_DATA                                                  ~34
   38    44      > JMP                                                      ->31
         45    >   FE_FREE                                                  $28
   42    46        INIT_FCALL                                               'var_dump'
         47        SEND_VAR                                                 !2
         48        DO_ICALL                                                 
         49      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
166.01 ms | 1392 KiB | 20 Q