3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [0, 1, 0, 1, 0, 0]; var_export( array_reduce( $array, function ($result, $b) { static $last; if (!$last || $b) { $result[] = $b; } $last = $b; return $result; }, [] ) );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IcO40
function name:  (null)
number of ops:  11
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    4     1        INIT_FCALL                                               'var_export'
    5     2        INIT_FCALL                                               'array_reduce'
    6     3        SEND_VAR                                                 !0
    7     4        DECLARE_LAMBDA_FUNCTION                          ~2      [0]
   14     5        SEND_VAL                                                 ~2
   15     6        SEND_VAL                                                 <array>
    5     7        DO_ICALL                                         $3      
   15     8        SEND_VAR                                                 $3
    4     9        DO_ICALL                                                 
   17    10      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 5, Position 2 = 6
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 9
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
Branch analysis from position: 6
filename:       /in/IcO40
function name:  {closure}
number of ops:  12
compiled vars:  !0 = $result, !1 = $b, !2 = $last
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    8     2        BIND_STATIC                                              !2
    9     3        BOOL_NOT                                         ~3      !2
          4      > JMPNZ_EX                                         ~3      ~3, ->6
          5    >   BOOL                                             ~3      !1
          6    > > JMPZ                                                     ~3, ->9
   10     7    >   ASSIGN_DIM                                               !0
          8        OP_DATA                                                  !1
   12     9    >   ASSIGN                                                   !2, !1
   13    10      > RETURN                                                   !0
   14    11*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.91 ms | 1011 KiB | 15 Q