3v4l.org

run code in 300+ PHP versions simultaneously
<?php function array_subtract(array $input) { $result = reset($input); // First element of the array foreach (array_slice($input, 1) as $value) { // Use array_slice to avoid subtracting the first element twice $result -= $value; // Subtract the value } return $result; // Return the result } $array = ["one" => 50, "two" => 6, 8, 9]; echo array_subtract($array); // Outputs 27
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/eUuPP
function name:  (null)
number of ops:  6
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   ASSIGN                                                   !0, <array>
   12     1        INIT_FCALL                                               'array_subtract'
          2        SEND_VAR                                                 !0
          3        DO_FCALL                                      0  $2      
          4        ECHO                                                     $2
          5      > RETURN                                                   1

Function array_subtract:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 10, Position 2 = 13
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 13
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
filename:       /in/eUuPP
function name:  array_subtract
number of ops:  16
compiled vars:  !0 = $input, !1 = $result, !2 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        INIT_FCALL                                               'reset'
          2        SEND_REF                                                 !0
          3        DO_ICALL                                         $3      
          4        ASSIGN                                                   !1, $3
    5     5        INIT_FCALL                                               'array_slice'
          6        SEND_VAR                                                 !0
          7        SEND_VAL                                                 1
          8        DO_ICALL                                         $5      
          9      > FE_RESET_R                                       $6      $5, ->13
         10    > > FE_FETCH_R                                               $6, !2, ->13
    6    11    >   ASSIGN_OP                                     2          !1, !2
    5    12      > JMP                                                      ->10
         13    >   FE_FREE                                                  $6
    8    14      > RETURN                                                   !1
    9    15*     > RETURN                                                   null

End of function array_subtract

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
137.04 ms | 1001 KiB | 16 Q