3v4l.org

run code in 300+ PHP versions simultaneously
<?php function arraySum(array $array) { $stack = [$array]; $sum = 0; while (($items = array_pop($stack))) { foreach ($items as $item) { if (is_array($item)) { $stack[] = $item; } else { $sum += $item; } } } return $sum; } echo arraySum([1, [1, 1], [1, [1, 1]]]);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ss2r8
function name:  (null)
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   INIT_FCALL                                               'arraysum'
          1        SEND_VAL                                                 <array>
          2        DO_FCALL                                      0  $0      
          3        ECHO                                                     $0
          4      > RETURN                                                   1

Function arraysum:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
2 jumps found. (Code = 44) Position 1 = 20, Position 2 = 5
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 14
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 14
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 12
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 14
2 jumps found. (Code = 44) Position 1 = 20, Position 2 = 5
Branch analysis from position: 20
Branch analysis from position: 5
Branch analysis from position: 14
filename:       /in/ss2r8
function name:  arraySum
number of ops:  22
compiled vars:  !0 = $array, !1 = $stack, !2 = $sum, !3 = $items, !4 = $item
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        INIT_ARRAY                                       ~5      !0
          2        ASSIGN                                                   !1, ~5
    5     3        ASSIGN                                                   !2, 0
    7     4      > JMP                                                      ->15
    8     5    > > FE_RESET_R                                       $8      !3, ->14
          6    > > FE_FETCH_R                                               $8, !4, ->14
    9     7    >   TYPE_CHECK                                  128          !4
          8      > JMPZ                                                     ~9, ->12
   10     9    >   ASSIGN_DIM                                               !1
         10        OP_DATA                                                  !4
    9    11      > JMP                                                      ->13
   13    12    >   ASSIGN_OP                                     1          !2, !4
    8    13    > > JMP                                                      ->6
         14    >   FE_FREE                                                  $8
    7    15    >   INIT_FCALL                                               'array_pop'
         16        SEND_REF                                                 !1
         17        DO_ICALL                                         $12     
         18        ASSIGN                                           ~13     !3, $12
         19      > JMPNZ                                                    ~13, ->5
   18    20    > > RETURN                                                   !2
   19    21*     > RETURN                                                   null

End of function arraysum

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.08 ms | 1454 KiB | 15 Q