3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array1 = ["banana","car","carrot"]; $needle = "car"; if (($index = array_search($needle, $array1)) !== false) { $array2[] = $array1[$index]; unset($array1[$index]); } var_export($array1); echo "\n---\n"; var_export($array2);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 13
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
filename:       /in/O7N8k
function name:  (null)
number of ops:  21
compiled vars:  !0 = $array1, !1 = $needle, !2 = $index, !3 = $array2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
    3     1        ASSIGN                                                   !1, 'car'
    4     2        INIT_FCALL                                               'array_search'
          3        SEND_VAR                                                 !1
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $6      
          6        ASSIGN                                           ~7      !2, $6
          7        TYPE_CHECK                                  1018          ~7
          8      > JMPZ                                                     ~8, ->13
    5     9    >   FETCH_DIM_R                                      ~10     !0, !2
         10        ASSIGN_DIM                                               !3
         11        OP_DATA                                                  ~10
    6    12        UNSET_DIM                                                !0, !2
    9    13    >   INIT_FCALL                                               'var_export'
         14        SEND_VAR                                                 !0
         15        DO_ICALL                                                 
   10    16        ECHO                                                     '%0A---%0A'
   11    17        INIT_FCALL                                               'var_export'
         18        SEND_VAR                                                 !3
         19        DO_ICALL                                                 
         20      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
171.09 ms | 1399 KiB | 17 Q