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); $ff = 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) $ff[] = $ff.''.$array2[$j]; } } print_r($ff);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 12
Branch analysis from position: 31
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 = 14
Branch analysis from position: 28
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 12
Branch analysis from position: 31
Branch analysis from position: 12
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 25
Branch analysis from position: 20
2 jumps found. (Code = 44) Position 1 = 28, Position 2 = 14
Branch analysis from position: 28
Branch analysis from position: 14
Branch analysis from position: 25
filename:       /in/Yt7Lc
function name:  (null)
number of ops:  35
compiled vars:  !0 = $array1, !1 = $array2, !2 = $num, !3 = $total, !4 = $ff, !5 = $i, !6 = $j
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
    3     1        ASSIGN                                                   !1, <array>
    5     2        COUNT                                            ~9      !1
          3        ASSIGN                                                   !2, ~9
    8     4        INIT_FCALL                                               'pow'
          5        SEND_VAL                                                 2
          6        SEND_VAR                                                 !2
          7        DO_ICALL                                         $11     
          8        ASSIGN                                                   !3, $11
    9     9        ASSIGN                                                   !4, <array>
   12    10        ASSIGN                                                   !5, 0
         11      > JMP                                                      ->29
   15    12    >   ASSIGN                                                   !6, 0
         13      > JMP                                                      ->26
   18    14    >   INIT_FCALL                                               'pow'
         15        SEND_VAL                                                 2
         16        SEND_VAR                                                 !6
         17        DO_ICALL                                         $16     
         18        BW_AND                                           ~17     !5, $16
         19      > JMPZ                                                     ~17, ->25
         20    >   CONCAT                                           ~19     !4, ''
         21        FETCH_DIM_R                                      ~20     !1, !6
         22        CONCAT                                           ~21     ~19, ~20
         23        ASSIGN_DIM                                               !4
         24        OP_DATA                                                  ~21
   15    25    >   PRE_INC                                                  !6
         26    >   IS_SMALLER                                               !6, !2
         27      > JMPNZ                                                    ~23, ->14
   12    28    >   PRE_INC                                                  !5
         29    >   IS_SMALLER                                               !5, !3
         30      > JMPNZ                                                    ~25, ->12
   22    31    >   INIT_FCALL                                               'print_r'
         32        SEND_VAR                                                 !4
         33        DO_ICALL                                                 
         34      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162.53 ms | 1404 KiB | 17 Q