3v4l.org

run code in 500+ PHP versions simultaneously
<?php $myarray = [ [0, 70, 19, 0], [0, 24, 14], // note missing 4th element [0, 15, 11, 0], [0, 15, 27, 0] ]; for ($i = sizeof($myarray)-2; $i>=0; --$i) { // start from 2nd last subarray, and move toward the start $max = max(sizeof($myarray[$i]), sizeof($myarray[$i+1])); // make sure all elements are accounted for for($k = 0; $k < $max; ++$k) { // iterate and perform subtractions / declarations $myarray[$i][$k] = (isset($myarray[$i][$k]) ? $myarray[$i][$k] : 0) - (isset($myarray[$i+1][$k]) ? $myarray[$i+1][$k] : 0); // declare/overwrite new values as encountered } } var_export($myarray);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 40
Branch analysis from position: 40
2 jumps found. (Code = 44) Position 1 = 42, Position 2 = 5
Branch analysis from position: 42
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 37
Branch analysis from position: 37
2 jumps found. (Code = 44) Position 1 = 39, Position 2 = 14
Branch analysis from position: 39
2 jumps found. (Code = 44) Position 1 = 42, Position 2 = 5
Branch analysis from position: 42
Branch analysis from position: 5
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 21
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
2 jumps found. (Code = 43) Position 1 = 26, Position 2 = 31
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
2 jumps found. (Code = 44) Position 1 = 39, Position 2 = 14
Branch analysis from position: 39
Branch analysis from position: 14
Branch analysis from position: 31
2 jumps found. (Code = 44) Position 1 = 39, Position 2 = 14
Branch analysis from position: 39
Branch analysis from position: 14
Branch analysis from position: 21
2 jumps found. (Code = 43) Position 1 = 26, Position 2 = 31
Branch analysis from position: 26
Branch analysis from position: 31
filename:       /in/V3n4E
function name:  (null)
number of ops:  46
compiled vars:  !0 = $myarray, !1 = $i, !2 = $max, !3 = $k
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                       !0, <array>
    9     1        COUNT                                                ~5      !0
          2        SUB                                                  ~6      ~5, 2
          3        ASSIGN                                                       !1, ~6
          4      > JMP                                                          ->40
   10     5    >   FETCH_DIM_R                                          ~8      !0, !1
          6        COUNT                                                ~9      ~8
          7        ADD                                                  ~10     !1, 1
          8        FETCH_DIM_R                                          ~11     !0, ~10
          9        COUNT                                                ~12     ~11
         10        FRAMELESS_ICALL_2                max                 ~13     ~9, ~12
         11        ASSIGN                                                       !2, ~13
   11    12        ASSIGN                                                       !3, 0
         13      > JMP                                                          ->37
   12    14    >   FETCH_DIM_IS                                         ~18     !0, !1
         15        ISSET_ISEMPTY_DIM_OBJ                             0          ~18, !3
         16      > JMPZ                                                         ~19, ->21
         17    >   FETCH_DIM_R                                          ~20     !0, !1
         18        FETCH_DIM_R                                          ~21     ~20, !3
         19        QM_ASSIGN                                            ~22     ~21
         20      > JMP                                                          ->22
         21    >   QM_ASSIGN                                            ~22     0
         22    >   ADD                                                  ~23     !1, 1
         23        FETCH_DIM_IS                                         ~24     !0, ~23
         24        ISSET_ISEMPTY_DIM_OBJ                             0          ~24, !3
         25      > JMPZ                                                         ~25, ->31
         26    >   ADD                                                  ~26     !1, 1
         27        FETCH_DIM_R                                          ~27     !0, ~26
         28        FETCH_DIM_R                                          ~28     ~27, !3
         29        QM_ASSIGN                                            ~29     ~28
         30      > JMP                                                          ->32
         31    >   QM_ASSIGN                                            ~29     0
         32    >   SUB                                                  ~30     ~22, ~29
         33        FETCH_DIM_W                                          $16     !0, !1
         34        ASSIGN_DIM                                                   $16, !3
         35        OP_DATA                                                      ~30
   11    36        PRE_INC                                                      !3
         37    >   IS_SMALLER                                                   !3, !2
         38      > JMPNZ                                                        ~32, ->14
    9    39    >   PRE_DEC                                                      !1
         40    >   IS_SMALLER_OR_EQUAL                                          0, !1
         41      > JMPNZ                                                        ~34, ->5
   16    42    >   INIT_FCALL                                                   'var_export'
         43        SEND_VAR                                                     !0
         44        DO_ICALL                                                     
         45      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
159.13 ms | 2276 KiB | 14 Q