3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getRunningTotal(array $array) { $generator = function(array $array) { $total = 0; foreach ($array as $key => $value) { $total += $value; yield $key => $total; } }; return iterator_to_array($generator($array)); } $a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; var_dump(getRunningTotal($a));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/QFtTY
function name:  (null)
number of ops:  8
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   ASSIGN                                                   !0, <array>
   15     1        INIT_FCALL                                               'var_dump'
          2        INIT_FCALL                                               'getrunningtotal'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0  $2      
          5        SEND_VAR                                                 $2
          6        DO_ICALL                                                 
          7      > RETURN                                                   1

Function getrunningtotal:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/QFtTY
function name:  getRunningTotal
number of ops:  11
compiled vars:  !0 = $array, !1 = $generator
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    3     1        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FQFtTY%3A3%240'
          2        ASSIGN                                                   !1, ~2
   10     3        INIT_FCALL                                               'iterator_to_array'
          4        INIT_DYNAMIC_CALL                                        !1
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0  $4      
          7        SEND_VAR                                                 $4
          8        DO_ICALL                                         $5      
          9      > RETURN                                                   $5
   11    10*     > RETURN                                                   null

End of function getrunningtotal

Function %00%7Bclosure%7D%2Fin%2FQFtTY%3A3%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 9
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 9
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 9
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 9
filename:       /in/QFtTY
function name:  {closure}
number of ops:  11
compiled vars:  !0 = $array, !1 = $total, !2 = $value, !3 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        GENERATOR_CREATE                                         
    4     2        ASSIGN                                                   !1, 0
    5     3      > FE_RESET_R                                       $5      !0, ->9
          4    > > FE_FETCH_R                                       ~6      $5, !2, ->9
          5    >   ASSIGN                                                   !3, ~6
    6     6        ASSIGN_OP                                     1          !1, !2
    7     7        YIELD                                                    !1, !3
    5     8      > JMP                                                      ->4
          9    >   FE_FREE                                                  $5
    9    10      > GENERATOR_RETURN                                         

End of function %00%7Bclosure%7D%2Fin%2FQFtTY%3A3%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.2 ms | 1403 KiB | 18 Q