3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = ['a' => 1, 'b' => 2, 'c' => 3, 'd' => 4]; var_dump(array_filter($arr, function($v) { return $v < 3; })); var_dump(array_filter($arr, function($k) { return $k == 'b'; }, ARRAY_FILTER_USE_KEY)); var_dump(array_filter($arr, function($v, $k) { return $k == 'b' || $v == 4; }, ARRAY_FILTER_USE_BOTH));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/cXQkC
function name:  (null)
number of ops:  28
compiled vars:  !0 = $arr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    5     1        INIT_FCALL                                               'var_dump'
          2        INIT_FCALL                                               'array_filter'
          3        SEND_VAR                                                 !0
          4        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FcXQkC%3A5%240'
    7     5        SEND_VAL                                                 ~2
          6        DO_ICALL                                         $3      
          7        SEND_VAR                                                 $3
          8        DO_ICALL                                                 
    9     9        INIT_FCALL                                               'var_dump'
         10        INIT_FCALL                                               'array_filter'
         11        SEND_VAR                                                 !0
         12        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FcXQkC%3A9%241'
   11    13        SEND_VAL                                                 ~5
         14        SEND_VAL                                                 2
         15        DO_ICALL                                         $6      
         16        SEND_VAR                                                 $6
         17        DO_ICALL                                                 
   13    18        INIT_FCALL                                               'var_dump'
         19        INIT_FCALL                                               'array_filter'
         20        SEND_VAR                                                 !0
         21        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FcXQkC%3A13%242'
   15    22        SEND_VAL                                                 ~8
         23        SEND_VAL                                                 1
         24        DO_ICALL                                         $9      
         25        SEND_VAR                                                 $9
         26        DO_ICALL                                                 
         27      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FcXQkC%3A5%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/cXQkC
function name:  {closure}
number of ops:  4
compiled vars:  !0 = $v
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
    6     1        IS_SMALLER                                       ~1      !0, 3
          2      > RETURN                                                   ~1
    7     3*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FcXQkC%3A5%240

Function %00%7Bclosure%7D%2Fin%2FcXQkC%3A9%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/cXQkC
function name:  {closure}
number of ops:  4
compiled vars:  !0 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
   10     1        IS_EQUAL                                         ~1      !0, 'b'
          2      > RETURN                                                   ~1
   11     3*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FcXQkC%3A9%241

Function %00%7Bclosure%7D%2Fin%2FcXQkC%3A13%242:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 4, Position 2 = 6
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
filename:       /in/cXQkC
function name:  {closure}
number of ops:  8
compiled vars:  !0 = $v, !1 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   14     2        IS_EQUAL                                         ~2      !1, 'b'
          3      > JMPNZ_EX                                         ~2      ~2, ->6
          4    >   IS_EQUAL                                         ~3      !0, 4
          5        BOOL                                             ~2      ~3
          6    > > RETURN                                                   ~2
   15     7*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FcXQkC%3A13%242

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
163.51 ms | 1400 KiB | 17 Q