3v4l.org

run code in 300+ PHP versions simultaneously
<?php // searching array $arr = array(111,112,113,114,115); $val = 113; if ( ($dex = array_search($val, $arr)) !== false) { // reconstruct the array … $arr = array_merge(array_slice($arr,0,$dex), array_slice($arr,$dex + 1)); } $delValue = 115; // using a “diff” comparison: $array = array_values(array_diff($arr, [$delValue])); var_dump($arr);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 24
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
filename:       /in/CsM8G
function name:  (null)
number of ops:  38
compiled vars:  !0 = $arr, !1 = $val, !2 = $dex, !3 = $delValue, !4 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   ASSIGN                                                   !0, <array>
    5     1        ASSIGN                                                   !1, 113
    7     2        INIT_FCALL                                               'array_search'
          3        SEND_VAR                                                 !1
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $7      
          6        ASSIGN                                           ~8      !2, $7
          7        TYPE_CHECK                                  1018          ~8
          8      > JMPZ                                                     ~9, ->24
    9     9    >   INIT_FCALL                                               'array_merge'
         10        INIT_FCALL                                               'array_slice'
         11        SEND_VAR                                                 !0
         12        SEND_VAL                                                 0
         13        SEND_VAR                                                 !2
         14        DO_ICALL                                         $10     
         15        SEND_VAR                                                 $10
   10    16        INIT_FCALL                                               'array_slice'
         17        SEND_VAR                                                 !0
         18        ADD                                              ~11     !2, 1
         19        SEND_VAL                                                 ~11
         20        DO_ICALL                                         $12     
         21        SEND_VAR                                                 $12
         22        DO_ICALL                                         $13     
    9    23        ASSIGN                                                   !0, $13
   13    24    >   ASSIGN                                                   !3, 115
   15    25        INIT_FCALL                                               'array_values'
         26        INIT_FCALL                                               'array_diff'
         27        SEND_VAR                                                 !0
         28        INIT_ARRAY                                       ~16     !3
         29        SEND_VAL                                                 ~16
         30        DO_ICALL                                         $17     
         31        SEND_VAR                                                 $17
         32        DO_ICALL                                         $18     
         33        ASSIGN                                                   !4, $18
   17    34        INIT_FCALL                                               'var_dump'
         35        SEND_VAR                                                 !0
         36        DO_ICALL                                                 
         37      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162.7 ms | 1396 KiB | 25 Q