3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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[] = $array2[$j] . ' '; } } print_r($temp);
based on ceeOF
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = 32
Branch analysis from position: 32
Jump found. Position 1 = 34, Position 2 = 14
Branch analysis from position: 34
Jump found. Position 1 = -2
Branch analysis from position: 14
Jump found. Position 1 = 28
Branch analysis from position: 28
Jump found. Position 1 = 30, Position 2 = 16
Branch analysis from position: 30
Jump found. Position 1 = 34, Position 2 = 14
Branch analysis from position: 34
Branch analysis from position: 14
Branch analysis from position: 16
Jump found. Position 1 = 22, Position 2 = 26
Branch analysis from position: 22
Jump found. Position 1 = 30, Position 2 = 16
Branch analysis from position: 30
Branch analysis from position: 16
Branch analysis from position: 26
filename:       /in/C3PCa
function name:  (null)
number of ops:  38
compiled vars:  !0 = $array1, !1 = $array2, !2 = $num, !3 = $total, !4 = $temp, !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        INIT_FCALL                                               'count'
         3        SEND_VAR                                                 !1
         4        DO_ICALL                                         $9      
         5        ASSIGN                                                   !2, $9
   8     6        INIT_FCALL                                               'pow'
         7        SEND_VAL                                                 2
         8        SEND_VAR                                                 !2
         9        DO_ICALL                                         $11     
        10        ASSIGN                                                   !3, $11
   9    11        ASSIGN                                                   !4, <array>
  12    12        ASSIGN                                                   !5, 0
        13      > JMP                                                      ->32
  14    14    >   ASSIGN                                                   !6, 0
        15      > JMP                                                      ->28
  17    16    >   INIT_FCALL                                               'pow'
        17        SEND_VAL                                                 2
        18        SEND_VAR                                                 !6
        19        DO_ICALL                                         $16     
        20        BW_AND                                           ~17     $16, !5
        21      > JMPZ                                                     ~17, ->26
        22    >   FETCH_DIM_R                                      $19     !1, !6
        23        CONCAT                                           ~20     $19, '+'
        24        ASSIGN_DIM                                               !4
        25        OP_DATA                                                  ~20
  14    26    >   POST_INC                                         ~21     !6
        27        FREE                                                     ~21
        28    >   IS_SMALLER                                       ~22     !6, !2
        29      > JMPNZ                                                    ~22, ->16
  12    30    >   POST_INC                                         ~23     !5
        31        FREE                                                     ~23
        32    >   IS_SMALLER                                       ~24     !5, !3
        33      > JMPNZ                                                    ~24, ->14
  21    34    >   INIT_FCALL                                               'print_r'
        35        SEND_VAR                                                 !4
        36        DO_ICALL                                                 
        37      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 7.2.0