3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ 0 => 0, 1 => 0.25, 2 => 0.75, 3 => 0.5, 4 => 0.5, 5 => 0.75 ]; $finalArray = []; foreach($array as $key=>$arr){ $finalArray[] = ($key > 0) ? array_sum(array_slice($array,$key)) : array_sum($array); } print_r($finalArray);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 23
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 23
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 16
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
filename:       /in/LU63i
function name:  (null)
number of ops:  28
compiled vars:  !0 = $array, !1 = $finalArray, !2 = $arr, !3 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   12     1        ASSIGN                                                   !1, <array>
   14     2      > FE_RESET_R                                       $6      !0, ->23
          3    > > FE_FETCH_R                                       ~7      $6, !2, ->23
          4    >   ASSIGN                                                   !3, ~7
   15     5        IS_SMALLER                                               0, !3
          6      > JMPZ                                                     ~10, ->16
          7    >   INIT_FCALL                                               'array_sum'
          8        INIT_FCALL                                               'array_slice'
          9        SEND_VAR                                                 !0
         10        SEND_VAR                                                 !3
         11        DO_ICALL                                         $11     
         12        SEND_VAR                                                 $11
         13        DO_ICALL                                         $12     
         14        QM_ASSIGN                                        ~13     $12
         15      > JMP                                                      ->20
         16    >   INIT_FCALL                                               'array_sum'
         17        SEND_VAR                                                 !0
         18        DO_ICALL                                         $14     
         19        QM_ASSIGN                                        ~13     $14
         20    >   ASSIGN_DIM                                               !1
         21        OP_DATA                                                  ~13
   14    22      > JMP                                                      ->3
         23    >   FE_FREE                                                  $6
   18    24        INIT_FCALL                                               'print_r'
         25        SEND_VAR                                                 !1
         26        DO_ICALL                                                 
         27      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
145.27 ms | 1013 KiB | 16 Q