3v4l.org

run code in 300+ PHP versions simultaneously
<?php function array_delete($array, $element) { return array_diff($array, [$element]); } $profiles = array('1', '2', 'patient'); if (in_array('patient', $profiles) ){ echo 'yesy'; $profiles = array_delete($profiles, 'patient'); } var_dump($profiles);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 12
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
filename:       /in/U2itk
function name:  (null)
number of ops:  16
compiled vars:  !0 = $profiles
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   ASSIGN                                                   !0, <array>
    7     1        INIT_FCALL                                               'in_array'
          2        SEND_VAL                                                 'patient'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $2      
          5      > JMPZ                                                     $2, ->12
    8     6    >   ECHO                                                     'yesy'
    9     7        INIT_FCALL                                               'array_delete'
          8        SEND_VAR                                                 !0
          9        SEND_VAL                                                 'patient'
         10        DO_FCALL                                      0  $3      
         11        ASSIGN                                                   !0, $3
   12    12    >   INIT_FCALL                                               'var_dump'
         13        SEND_VAR                                                 !0
         14        DO_ICALL                                                 
         15      > RETURN                                                   1

Function array_delete:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/U2itk
function name:  array_delete
number of ops:  9
compiled vars:  !0 = $array, !1 = $element
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    3     2        INIT_FCALL                                               'array_diff'
          3        SEND_VAR                                                 !0
          4        INIT_ARRAY                                       ~2      !1
          5        SEND_VAL                                                 ~2
          6        DO_ICALL                                         $3      
          7      > RETURN                                                   $3
    4     8*     > RETURN                                                   null

End of function array_delete

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.75 ms | 1398 KiB | 20 Q