3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array1 = array('A', 'B'); $array2 = array('1', '2', '3'); $num = count($array2); $comb = array(); //The total number of possible combinations $total = pow(2, $num); //Loop through each possible combination for ($i = 0; $i < $total; $i++) { $flag = ''; //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) $flag = $flag.''.$array2[$j]; } if(!empty($flag)) $comb[] = $flag; } print_r($comb); //foreahc
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 34
Branch analysis from position: 34
2 jumps found. (Code = 44) Position 1 = 36, Position 2 = 12
Branch analysis from position: 36
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
2 jumps found. (Code = 44) Position 1 = 28, Position 2 = 15
Branch analysis from position: 28
2 jumps found. (Code = 43) Position 1 = 31, Position 2 = 33
Branch analysis from position: 31
2 jumps found. (Code = 44) Position 1 = 36, Position 2 = 12
Branch analysis from position: 36
Branch analysis from position: 12
Branch analysis from position: 33
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 25
Branch analysis from position: 21
2 jumps found. (Code = 44) Position 1 = 28, Position 2 = 15
Branch analysis from position: 28
Branch analysis from position: 15
Branch analysis from position: 25
filename:       /in/6vadJ
function name:  (null)
number of ops:  40
compiled vars:  !0 = $array1, !1 = $array2, !2 = $num, !3 = $comb, !4 = $total, !5 = $i, !6 = $flag, !7 = $j
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
    6     4        ASSIGN                                                   !3, <array>
    9     5        INIT_FCALL                                               'pow'
          6        SEND_VAL                                                 2
          7        SEND_VAR                                                 !2
          8        DO_ICALL                                         $13     
          9        ASSIGN                                                   !4, $13
   12    10        ASSIGN                                                   !5, 0
         11      > JMP                                                      ->34
   14    12    >   ASSIGN                                                   !6, ''
   16    13        ASSIGN                                                   !7, 0
         14      > JMP                                                      ->26
   19    15    >   INIT_FCALL                                               'pow'
         16        SEND_VAL                                                 2
         17        SEND_VAR                                                 !7
         18        DO_ICALL                                         $18     
         19        BW_AND                                           ~19     !5, $18
         20      > JMPZ                                                     ~19, ->25
         21    >   CONCAT                                           ~20     !6, ''
         22        FETCH_DIM_R                                      ~21     !1, !7
         23        CONCAT                                           ~22     ~20, ~21
         24        ASSIGN                                                   !6, ~22
   16    25    >   PRE_INC                                                  !7
         26    >   IS_SMALLER                                               !7, !2
         27      > JMPNZ                                                    ~25, ->15
   21    28    >   ISSET_ISEMPTY_CV                                 ~26     !6
         29        BOOL_NOT                                         ~27     ~26
         30      > JMPZ                                                     ~27, ->33
   22    31    >   ASSIGN_DIM                                               !3
         32        OP_DATA                                                  !6
   12    33    >   PRE_INC                                                  !5
         34    >   IS_SMALLER                                               !5, !4
         35      > JMPNZ                                                    ~30, ->12
   25    36    >   INIT_FCALL                                               'print_r'
         37        SEND_VAR                                                 !3
         38        DO_ICALL                                                 
   27    39      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
147.23 ms | 1400 KiB | 17 Q