3v4l.org

run code in 300+ PHP versions simultaneously
<?php function removeSomeElements(&$arr) { for ($i = 0; $i<count($arr); $i++) { $c = $arr[$i]; if ($c > 2) { echo "Element $c found at $i\n"; unset($arr[$i]); } } print_r($arr); // misses middle element return true; } $t = [0, 3, 1]; print_r($t); // original array $success = removeSomeElements($t); print_r($t); // should be missing middle element, but everything is here
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DaTK7
function name:  (null)
number of ops:  12
compiled vars:  !0 = $t, !1 = $success
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   ASSIGN                                                   !0, <array>
   18     1        INIT_FCALL                                               'print_r'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                                 
   19     4        INIT_FCALL                                               'removesomeelements'
          5        SEND_REF                                                 !0
          6        DO_FCALL                                      0  $4      
          7        ASSIGN                                                   !1, $4
   20     8        INIT_FCALL                                               'print_r'
          9        SEND_VAR                                                 !0
         10        DO_ICALL                                                 
         11      > RETURN                                                   1

Function removesomeelements:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
2 jumps found. (Code = 44) Position 1 = 18, Position 2 = 3
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 14
Branch analysis from position: 7
2 jumps found. (Code = 44) Position 1 = 18, Position 2 = 3
Branch analysis from position: 18
Branch analysis from position: 3
Branch analysis from position: 14
filename:       /in/DaTK7
function name:  removeSomeElements
number of ops:  23
compiled vars:  !0 = $arr, !1 = $i, !2 = $c
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    5     1        ASSIGN                                                   !1, 0
          2      > JMP                                                      ->15
    6     3    >   FETCH_DIM_R                                      ~4      !0, !1
          4        ASSIGN                                                   !2, ~4
    7     5        IS_SMALLER                                               2, !2
          6      > JMPZ                                                     ~6, ->14
    8     7    >   ROPE_INIT                                     5  ~8      'Element+'
          8        ROPE_ADD                                      1  ~8      ~8, !2
          9        ROPE_ADD                                      2  ~8      ~8, '+found+at+'
         10        ROPE_ADD                                      3  ~8      ~8, !1
         11        ROPE_END                                      4  ~7      ~8, '%0A'
         12        ECHO                                                     ~7
    9    13        UNSET_DIM                                                !0, !1
    5    14    >   PRE_INC                                                  !1
         15    >   COUNT                                            ~12     !0
         16        IS_SMALLER                                               !1, ~12
         17      > JMPNZ                                                    ~13, ->3
   12    18    >   INIT_FCALL                                               'print_r'
         19        SEND_VAR                                                 !0
         20        DO_ICALL                                                 
   13    21      > RETURN                                                   <true>
   14    22*     > RETURN                                                   null

End of function removesomeelements

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
145.44 ms | 1407 KiB | 16 Q