3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = [ [ [4,4,6,8,7,4,3], [4,4,6,8,7,4,3], ], [ [4,4,6,8,7,4,3], [43,6,8,31,2,1], ], [4,5,6,8] ]; function sumRecursive($carry, $item) { if(is_array($item)){ return array_reduce($item, 'sumRecursive', $carry); } return $carry+$item ; } $sum = sumRecursive(0, $arr); var_dump($sum);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/FuGtf
function name:  (null)
number of ops:  10
compiled vars:  !0 = $arr, !1 = $sum
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   21     1        INIT_FCALL                                               'sumrecursive'
          2        SEND_VAL                                                 0
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0  $3      
          5        ASSIGN                                                   !1, $3
   23     6        INIT_FCALL                                               'var_dump'
          7        SEND_VAR                                                 !1
          8        DO_ICALL                                                 
          9      > RETURN                                                   1

Function sumrecursive:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 10
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/FuGtf
function name:  sumRecursive
number of ops:  13
compiled vars:  !0 = $carry, !1 = $item
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   16     2        TYPE_CHECK                                  128          !1
          3      > JMPZ                                                     ~2, ->10
   17     4    >   INIT_FCALL                                               'array_reduce'
          5        SEND_VAR                                                 !1
          6        SEND_VAL                                                 'sumRecursive'
          7        SEND_VAR                                                 !0
          8        DO_ICALL                                         $3      
          9      > RETURN                                                   $3
   19    10    >   ADD                                              ~4      !0, !1
         11      > RETURN                                                   ~4
   20    12*     > RETURN                                                   null

End of function sumrecursive

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
141.59 ms | 1402 KiB | 18 Q