3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a = ["abc", "defs", "ghi"]; $b = ["abcs", "def", "ghis"]; $temp = array_map(null, $a, $b); function combinations($arrays) { $result = []; $arrays = array_values($arrays); $sizeIn = sizeof($arrays); $size = $sizeIn > 0 ? 1 : 0; foreach ($arrays as $array) { $size = $size * sizeof($array); } for ($i = 0; $i < $size; $i++) { $result[$i] = []; for ($j = 0; $j < $sizeIn; $j++) { array_push($result[$i], current($arrays[$j])); } for ($j = ($sizeIn - 1); $j >= 0; $j--) { if (next($arrays[$j])) { break; } elseif (isset($arrays[$j])) { reset($arrays[$j]); } } } return $result; } $res = combinations($temp); $temp = array_map(function($item){ return implode(" ", $item); },$res); foreach($temp as $val){ echo $val."\n"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 19, Position 2 = 23
Branch analysis from position: 19
2 jumps found. (Code = 78) Position 1 = 20, Position 2 = 23
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
filename:       /in/EoXmD
function name:  (null)
number of ops:  25
compiled vars:  !0 = $a, !1 = $b, !2 = $temp, !3 = $res, !4 = $val
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
    3     1        ASSIGN                                                   !1, <array>
    4     2        INIT_FCALL                                               'array_map'
          3        SEND_VAL                                                 null
          4        SEND_VAR                                                 !0
          5        SEND_VAR                                                 !1
          6        DO_ICALL                                         $7      
          7        ASSIGN                                                   !2, $7
   29     8        INIT_FCALL                                               'combinations'
          9        SEND_VAR                                                 !2
         10        DO_FCALL                                      0  $9      
         11        ASSIGN                                                   !3, $9
   30    12        INIT_FCALL                                               'array_map'
         13        DECLARE_LAMBDA_FUNCTION                          ~11     [0]
   32    14        SEND_VAL                                                 ~11
         15        SEND_VAR                                                 !3
   30    16        DO_ICALL                                         $12     
         17        ASSIGN                                                   !2, $12
   33    18      > FE_RESET_R                                       $14     !2, ->23
         19    > > FE_FETCH_R                                               $14, !4, ->23
   34    20    >   CONCAT                                           ~15     !4, '%0A'
         21        ECHO                                                     ~15
   33    22      > JMP                                                      ->19
         23    >   FE_FREE                                                  $14
   35    24      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/EoXmD
function name:  {closure}
number of ops:  7
compiled vars:  !0 = $item
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   RECV                                             !0      
   31     1        INIT_FCALL                                               'implode'
          2        SEND_VAL                                                 '+'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $1      
          5      > RETURN                                                   $1
   32     6*     > RETURN                                                   null

End of Dynamic Function 0

Function combinations:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 12
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
2 jumps found. (Code = 77) Position 1 = 15, Position 2 = 20
Branch analysis from position: 15
2 jumps found. (Code = 78) Position 1 = 16, Position 2 = 20
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 59
Branch analysis from position: 59
2 jumps found. (Code = 44) Position 1 = 61, Position 2 = 23
Branch analysis from position: 61
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 37
Branch analysis from position: 37
2 jumps found. (Code = 44) Position 1 = 39, Position 2 = 27
Branch analysis from position: 39
1 jumps found. (Code = 42) Position 1 = 56
Branch analysis from position: 56
2 jumps found. (Code = 44) Position 1 = 58, Position 2 = 42
Branch analysis from position: 58
2 jumps found. (Code = 44) Position 1 = 61, Position 2 = 23
Branch analysis from position: 61
Branch analysis from position: 23
Branch analysis from position: 42
2 jumps found. (Code = 43) Position 1 = 47, Position 2 = 49
Branch analysis from position: 47
1 jumps found. (Code = 42) Position 1 = 58
Branch analysis from position: 58
Branch analysis from position: 49
2 jumps found. (Code = 43) Position 1 = 51, Position 2 = 55
Branch analysis from position: 51
2 jumps found. (Code = 44) Position 1 = 58, Position 2 = 42
Branch analysis from position: 58
Branch analysis from position: 42
Branch analysis from position: 55
Branch analysis from position: 27
2 jumps found. (Code = 44) Position 1 = 39, Position 2 = 27
Branch analysis from position: 39
Branch analysis from position: 27
Branch analysis from position: 20
Branch analysis from position: 12
2 jumps found. (Code = 77) Position 1 = 15, Position 2 = 20
Branch analysis from position: 15
Branch analysis from position: 20
filename:       /in/EoXmD
function name:  combinations
number of ops:  63
compiled vars:  !0 = $arrays, !1 = $result, !2 = $sizeIn, !3 = $size, !4 = $array, !5 = $i, !6 = $j
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
    7     1        ASSIGN                                                   !1, <array>
    8     2        INIT_FCALL                                               'array_values'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $8      
          5        ASSIGN                                                   !0, $8
    9     6        COUNT                                            ~10     !0
          7        ASSIGN                                                   !2, ~10
   10     8        IS_SMALLER                                               0, !2
          9      > JMPZ                                                     ~12, ->12
         10    >   QM_ASSIGN                                        ~13     1
         11      > JMP                                                      ->13
         12    >   QM_ASSIGN                                        ~13     0
         13    >   ASSIGN                                                   !3, ~13
   11    14      > FE_RESET_R                                       $15     !0, ->20
         15    > > FE_FETCH_R                                               $15, !4, ->20
   12    16    >   COUNT                                            ~16     !4
         17        MUL                                              ~17     !3, ~16
         18        ASSIGN                                                   !3, ~17
   11    19      > JMP                                                      ->15
         20    >   FE_FREE                                                  $15
   14    21        ASSIGN                                                   !5, 0
         22      > JMP                                                      ->59
   15    23    >   ASSIGN_DIM                                               !1, !5
         24        OP_DATA                                                  <array>
   16    25        ASSIGN                                                   !6, 0
         26      > JMP                                                      ->37
   17    27    >   INIT_FCALL                                               'array_push'
         28        FETCH_DIM_W                                      $22     !1, !5
         29        SEND_REF                                                 $22
         30        INIT_FCALL                                               'current'
         31        FETCH_DIM_R                                      ~23     !0, !6
         32        SEND_VAL                                                 ~23
         33        DO_ICALL                                         $24     
         34        SEND_VAR                                                 $24
         35        DO_ICALL                                                 
   16    36        PRE_INC                                                  !6
         37    >   IS_SMALLER                                               !6, !2
         38      > JMPNZ                                                    ~27, ->27
   19    39    >   SUB                                              ~28     !2, 1
         40        ASSIGN                                                   !6, ~28
         41      > JMP                                                      ->56
   20    42    >   INIT_FCALL                                               'next'
         43        FETCH_DIM_W                                      $30     !0, !6
         44        SEND_REF                                                 $30
         45        DO_ICALL                                         $31     
         46      > JMPZ                                                     $31, ->49
   21    47    > > JMP                                                      ->58
   20    48*       JMP                                                      ->55
   22    49    >   ISSET_ISEMPTY_DIM_OBJ                         0          !0, !6
         50      > JMPZ                                                     ~32, ->55
   23    51    >   INIT_FCALL                                               'reset'
         52        FETCH_DIM_W                                      $33     !0, !6
         53        SEND_REF                                                 $33
         54        DO_ICALL                                                 
   19    55    >   PRE_DEC                                                  !6
         56    >   IS_SMALLER_OR_EQUAL                                      0, !6
         57      > JMPNZ                                                    ~36, ->42
   14    58    >   PRE_INC                                                  !5
         59    >   IS_SMALLER                                               !5, !3
         60      > JMPNZ                                                    ~38, ->23
   27    61    > > RETURN                                                   !1
   28    62*     > RETURN                                                   null

End of function combinations

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146.14 ms | 1020 KiB | 21 Q