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

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
147.63 ms | 1400 KiB | 17 Q