3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = ['x', 'y', 'z']; $mask = 5; $count = count($arr); $mask &= pow(2, $count); $offset = $count - 1; $result = []; foreach ($arr as $k => $v) { if ($mask >> ($offset - $k)) { $result[] = $v; } } var_dump($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 13, Position 2 = 21
Branch analysis from position: 13
2 jumps found. (Code = 78) Position 1 = 14, Position 2 = 21
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 20
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 20
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
filename:       /in/IdKs9
function name:  (null)
number of ops:  26
compiled vars:  !0 = $arr, !1 = $mask, !2 = $count, !3 = $offset, !4 = $result, !5 = $v, !6 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    4     1        ASSIGN                                                   !1, 5
    6     2        COUNT                                            ~9      !0
          3        ASSIGN                                                   !2, ~9
    7     4        INIT_FCALL                                               'pow'
          5        SEND_VAL                                                 2
          6        SEND_VAR                                                 !2
          7        DO_ICALL                                         $11     
          8        ASSIGN_OP                                    10          !1, $11
    8     9        SUB                                              ~13     !2, 1
         10        ASSIGN                                                   !3, ~13
   10    11        ASSIGN                                                   !4, <array>
   11    12      > FE_RESET_R                                       $16     !0, ->21
         13    > > FE_FETCH_R                                       ~17     $16, !5, ->21
         14    >   ASSIGN                                                   !6, ~17
   12    15        SUB                                              ~19     !3, !6
         16        SR                                               ~20     !1, ~19
         17      > JMPZ                                                     ~20, ->20
   13    18    >   ASSIGN_DIM                                               !4
         19        OP_DATA                                                  !5
   11    20    > > JMP                                                      ->13
         21    >   FE_FREE                                                  $16
   17    22        INIT_FCALL                                               'var_dump'
         23        SEND_VAR                                                 !4
         24        DO_ICALL                                                 
         25      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.21 ms | 1395 KiB | 17 Q