3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array1 = array('A', 'B'); $array2 = array('1', '2', '3'); $num = count($array2); //The total number of possible combinations $total = pow(2, $num); $temp = array(); //Loop through each possible combination for ($i = 0; $i < $total; $i++) { //For each combination check if each bit is set for ($j = 0; $j < $num; $j++) { //Is bit $j set in $i? if (pow(2, $j) & $i) $temp[] = $words[$j]; } } print_r($temp);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 27
Branch analysis from position: 27
2 jumps found. (Code = 44) Position 1 = 29, Position 2 = 12
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
2 jumps found. (Code = 44) Position 1 = 26, Position 2 = 14
Branch analysis from position: 26
2 jumps found. (Code = 44) Position 1 = 29, Position 2 = 12
Branch analysis from position: 29
Branch analysis from position: 12
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 23
Branch analysis from position: 20
2 jumps found. (Code = 44) Position 1 = 26, Position 2 = 14
Branch analysis from position: 26
Branch analysis from position: 14
Branch analysis from position: 23
filename:       /in/lGIRl
function name:  (null)
number of ops:  33
compiled vars:  !0 = $array1, !1 = $array2, !2 = $num, !3 = $total, !4 = $temp, !5 = $i, !6 = $j, !7 = $words
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
    3     1        ASSIGN                                                   !1, <array>
    5     2        COUNT                                            ~10     !1
          3        ASSIGN                                                   !2, ~10
    8     4        INIT_FCALL                                               'pow'
          5        SEND_VAL                                                 2
          6        SEND_VAR                                                 !2
          7        DO_ICALL                                         $12     
          8        ASSIGN                                                   !3, $12
    9     9        ASSIGN                                                   !4, <array>
   12    10        ASSIGN                                                   !5, 0
         11      > JMP                                                      ->27
   14    12    >   ASSIGN                                                   !6, 0
         13      > JMP                                                      ->24
   17    14    >   INIT_FCALL                                               'pow'
         15        SEND_VAL                                                 2
         16        SEND_VAR                                                 !6
         17        DO_ICALL                                         $17     
         18        BW_AND                                           ~18     !5, $17
         19      > JMPZ                                                     ~18, ->23
         20    >   FETCH_DIM_R                                      ~20     !7, !6
         21        ASSIGN_DIM                                               !4
         22        OP_DATA                                                  ~20
   14    23    >   PRE_INC                                                  !6
         24    >   IS_SMALLER                                               !6, !2
         25      > JMPNZ                                                    ~22, ->14
   12    26    >   PRE_INC                                                  !5
         27    >   IS_SMALLER                                               !5, !3
         28      > JMPNZ                                                    ~24, ->12
   21    29    >   INIT_FCALL                                               'print_r'
         30        SEND_VAR                                                 !4
         31        DO_ICALL                                                 
         32      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162.23 ms | 1396 KiB | 17 Q