3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Solution { /** * @param Integer[] $nums * @param Integer $val * @return Integer */ function removeElement(&$nums, $val) { $k = 0; foreach ($nums as $i => $v) { if ($v !== $val) { $k++; } else { unset($nums[$i]); } } var_dump($k, $nums); } } (new Solution)->removeElement([3,2,2,3], 3);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3j2T6
function name:  (null)
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   NEW                                              $0      'Solution'
          1        DO_FCALL                                      0          
          2        INIT_METHOD_CALL                                         $0, 'removeElement'
          3        SEND_VAL_EX                                              <array>
          4        SEND_VAL_EX                                              3
          5        DO_FCALL                                      0          
          6      > RETURN                                                   1

Class Solution:
Function removeelement:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 12
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 12
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 10
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
filename:       /in/3j2T6
function name:  removeElement
number of ops:  18
compiled vars:  !0 = $nums, !1 = $val, !2 = $k, !3 = $v, !4 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   11     2        ASSIGN                                                   !2, 0
   12     3      > FE_RESET_R                                       $6      !0, ->12
          4    > > FE_FETCH_R                                       ~7      $6, !3, ->12
          5    >   ASSIGN                                                   !4, ~7
   13     6        IS_NOT_IDENTICAL                                         !3, !1
          7      > JMPZ                                                     ~9, ->10
   14     8    >   PRE_INC                                                  !2
   13     9      > JMP                                                      ->11
   16    10    >   UNSET_DIM                                                !0, !4
   12    11    > > JMP                                                      ->4
         12    >   FE_FREE                                                  $6
   19    13        INIT_FCALL                                               'var_dump'
         14        SEND_VAR                                                 !2
         15        SEND_VAR                                                 !0
         16        DO_ICALL                                                 
   20    17      > RETURN                                                   null

End of function removeelement

End of class Solution.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
142.7 ms | 1006 KiB | 14 Q