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) { var_dump($offset, $k); 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 = 25
Branch analysis from position: 13
2 jumps found. (Code = 78) Position 1 = 14, Position 2 = 25
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 24
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 24
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
filename:       /in/c8mLY
function name:  (null)
number of ops:  30
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, ->25
         13    > > FE_FETCH_R                                       ~17     $16, !5, ->25
         14    >   ASSIGN                                                   !6, ~17
   12    15        INIT_FCALL                                               'var_dump'
         16        SEND_VAR                                                 !3
         17        SEND_VAR                                                 !6
         18        DO_ICALL                                                 
   13    19        SUB                                              ~20     !3, !6
         20        SR                                               ~21     !1, ~20
         21      > JMPZ                                                     ~21, ->24
   14    22    >   ASSIGN_DIM                                               !4
         23        OP_DATA                                                  !5
   11    24    > > JMP                                                      ->13
         25    >   FE_FREE                                                  $16
   18    26        INIT_FCALL                                               'var_dump'
         27        SEND_VAR                                                 !4
         28        DO_ICALL                                                 
         29      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
183.02 ms | 1396 KiB | 17 Q