3v4l.org

run code in 300+ PHP versions simultaneously
<?php function array_greedy_diff($x, $y) { $output = $x; for($i = $j = 0; $i < count($x) && j < count($y); ) { if ($x[i] == $y[j]) { unset($output[i]); $x++; } $j++; } return $output; } $a = array(1,2,3,1,2,3); $b = array(1,2,3); var_dump(array_greedy_diff($a, $b));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/CSJjH
function name:  (null)
number of ops:  10
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   ASSIGN                                                   !0, <array>
   16     1        ASSIGN                                                   !1, <array>
   17     2        INIT_FCALL                                               'var_dump'
          3        INIT_FCALL                                               'array_greedy_diff'
          4        SEND_VAR                                                 !0
          5        SEND_VAR                                                 !1
          6        DO_FCALL                                      0  $4      
          7        SEND_VAR                                                 $4
          8        DO_ICALL                                                 
          9      > RETURN                                                   1

Function array_greedy_diff:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
2 jumps found. (Code = 46) Position 1 = 19, Position 2 = 23
Branch analysis from position: 19
2 jumps found. (Code = 44) Position 1 = 24, Position 2 = 6
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 15
Branch analysis from position: 12
2 jumps found. (Code = 46) Position 1 = 19, Position 2 = 23
Branch analysis from position: 19
Branch analysis from position: 23
Branch analysis from position: 15
Branch analysis from position: 23
filename:       /in/CSJjH
function name:  array_greedy_diff
number of ops:  26
compiled vars:  !0 = $x, !1 = $y, !2 = $output, !3 = $i, !4 = $j
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    4     2        ASSIGN                                                   !2, !0
    5     3        ASSIGN                                           ~6      !4, 0
          4        ASSIGN                                                   !3, ~6
          5      > JMP                                                      ->16
    6     6    >   FETCH_CONSTANT                                   ~8      'i'
          7        FETCH_DIM_R                                      ~9      !0, ~8
          8        FETCH_CONSTANT                                   ~10     'j'
          9        FETCH_DIM_R                                      ~11     !1, ~10
         10        IS_EQUAL                                                 ~9, ~11
         11      > JMPZ                                                     ~12, ->15
    7    12    >   FETCH_CONSTANT                                   ~13     'i'
         13        UNSET_DIM                                                !2, ~13
    8    14        PRE_INC                                                  !0
   10    15    >   PRE_INC                                                  !4
    5    16    >   COUNT                                            ~16     !0
         17        IS_SMALLER                                       ~17     !3, ~16
         18      > JMPZ_EX                                          ~17     ~17, ->23
         19    >   FETCH_CONSTANT                                   ~18     'j'
         20        COUNT                                            ~19     !1
         21        IS_SMALLER                                       ~20     ~18, ~19
         22        BOOL                                             ~17     ~20
         23    > > JMPNZ                                                    ~17, ->6
   12    24    > > RETURN                                                   !2
   13    25*     > RETURN                                                   null

End of function array_greedy_diff

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.9 ms | 1403 KiB | 16 Q