3v4l.org

run code in 300+ PHP versions simultaneously
<?php $walk_arr = [ 0 => "A", 1 => "B", 3 => "D", 5 => "F", ]; global $stop_walk; $stop_walk = false; $walk_func = function(&$v, $k) { global $stop_walk; if ($k === 3) { $stop_walk = true; } if ($stop_walk) { return; } $v .= " changed"; }; unset($stop_walk); array_walk($walk_arr, $walk_func); print_r($walk_arr); print $stop_walk;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6kceo
function name:  (null)
number of ops:  15
compiled vars:  !0 = $walk_arr, !1 = $stop_walk, !2 = $walk_func
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
    8     1        BIND_GLOBAL                                              !1, 'stop_walk'
    9     2        ASSIGN                                                   !1, <false>
   10     3        DECLARE_LAMBDA_FUNCTION                          ~5      [0]
          4        ASSIGN                                                   !2, ~5
   20     5        UNSET_CV                                                 !1
   22     6        INIT_FCALL                                               'array_walk'
          7        SEND_REF                                                 !0
          8        SEND_VAR                                                 !2
          9        DO_ICALL                                                 
   23    10        INIT_FCALL                                               'print_r'
         11        SEND_VAR                                                 !0
         12        DO_ICALL                                                 
   24    13        ECHO                                                     !1
   25    14      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 6
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 8
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
filename:       /in/6kceo
function name:  {closure}
number of ops:  10
compiled vars:  !0 = $v, !1 = $k, !2 = $stop_walk
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   11     2        BIND_GLOBAL                                              !2, 'stop_walk'
   12     3        IS_IDENTICAL                                             !1, 3
          4      > JMPZ                                                     ~3, ->6
   13     5    >   ASSIGN                                                   !2, <true>
   15     6    > > JMPZ                                                     !2, ->8
   16     7    > > RETURN                                                   null
   18     8    >   ASSIGN_OP                                     8          !0, '+changed'
   19     9      > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
235.85 ms | 1000 KiB | 15 Q