3v4l.org

run code in 300+ PHP versions simultaneously
<?php $input = array(1, 2, 3, 4, 5, 6); // Creates a new anonymous function and assigns it to a variable $filter_even = function($item) { return ($item % 2) == 0; }; // Built-in array_filter accepts both the data and the function $output = array_filter($input, $filter_even); // The function doesn't need to be assigned to a variable. This is valid too: $output = array_filter($input, function($item) { return ($item % 2) == 0; }); print_r($output);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6CbEv
function name:  (null)
number of ops:  18
compiled vars:  !0 = $input, !1 = $filter_even, !2 = $output
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
    5     1        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F6CbEv%3A5%240'
          2        ASSIGN                                                   !1, ~4
   10     3        INIT_FCALL                                               'array_filter'
          4        SEND_VAR                                                 !0
          5        SEND_VAR                                                 !1
          6        DO_ICALL                                         $6      
          7        ASSIGN                                                   !2, $6
   13     8        INIT_FCALL                                               'array_filter'
          9        SEND_VAR                                                 !0
         10        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F6CbEv%3A13%241'
   15    11        SEND_VAL                                                 ~8
         12        DO_ICALL                                         $9      
   13    13        ASSIGN                                                   !2, $9
   17    14        INIT_FCALL                                               'print_r'
         15        SEND_VAR                                                 !2
         16        DO_ICALL                                                 
         17      > RETURN                                                   1

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

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

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

End of function %00%7Bclosure%7D%2Fin%2F6CbEv%3A13%241

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162.38 ms | 1396 KiB | 17 Q