3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = ['x', 'y', 'z']; $mask = 5; $keys = decbin($mask); $i = 0; $result = array_filter($arr, function($val) use($keys, &$i) { return (bool)$keys[$i++]; }); var_dump($result);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/JdYjI
function name:  (null)
number of ops:  19
compiled vars:  !0 = $arr, !1 = $mask, !2 = $keys, !3 = $i, !4 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    4     1        ASSIGN                                                   !1, 5
    6     2        INIT_FCALL                                               'decbin'
          3        SEND_VAR                                                 !1
          4        DO_ICALL                                         $7      
          5        ASSIGN                                                   !2, $7
    7     6        ASSIGN                                                   !3, 0
    9     7        INIT_FCALL                                               'array_filter'
          8        SEND_VAR                                                 !0
          9        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FJdYjI%3A9%240'
         10        BIND_LEXICAL                                             ~10, !2
         11        BIND_LEXICAL                                             ~10, !3
         12        SEND_VAL                                                 ~10
         13        DO_ICALL                                         $11     
         14        ASSIGN                                                   !4, $11
   11    15        INIT_FCALL                                               'var_dump'
         16        SEND_VAR                                                 !4
         17        DO_ICALL                                                 
         18      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FJdYjI%3A9%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/JdYjI
function name:  {closure}
number of ops:  8
compiled vars:  !0 = $val, !1 = $keys, !2 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
          2        BIND_STATIC                                              !2
          3        POST_INC                                         ~3      !2
          4        FETCH_DIM_R                                      ~4      !1, ~3
          5        BOOL                                             ~5      ~4
          6      > RETURN                                                   ~5
          7*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FJdYjI%3A9%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.98 ms | 1388 KiB | 19 Q