3v4l.org

run code in 300+ 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 = 43
Branch analysis from position: 43
2 jumps found. (Code = 44) Position 1 = 45, Position 2 = 5
Branch analysis from position: 45
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 40
Branch analysis from position: 40
2 jumps found. (Code = 44) Position 1 = 42, Position 2 = 17
Branch analysis from position: 42
2 jumps found. (Code = 44) Position 1 = 45, Position 2 = 5
Branch analysis from position: 45
Branch analysis from position: 5
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 24
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
2 jumps found. (Code = 43) Position 1 = 29, Position 2 = 34
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 35
Branch analysis from position: 35
2 jumps found. (Code = 44) Position 1 = 42, Position 2 = 17
Branch analysis from position: 42
Branch analysis from position: 17
Branch analysis from position: 34
2 jumps found. (Code = 44) Position 1 = 42, Position 2 = 17
Branch analysis from position: 42
Branch analysis from position: 17
Branch analysis from position: 24
2 jumps found. (Code = 43) Position 1 = 29, Position 2 = 34
Branch analysis from position: 29
Branch analysis from position: 34
filename:       /in/V3n4E
function name:  (null)
number of ops:  49
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                                                      ->43
   10     5    >   INIT_FCALL                                               'max'
          6        FETCH_DIM_R                                      ~8      !0, !1
          7        COUNT                                            ~9      ~8
          8        SEND_VAL                                                 ~9
          9        ADD                                              ~10     !1, 1
         10        FETCH_DIM_R                                      ~11     !0, ~10
         11        COUNT                                            ~12     ~11
         12        SEND_VAL                                                 ~12
         13        DO_ICALL                                         $13     
         14        ASSIGN                                                   !2, $13
   11    15        ASSIGN                                                   !3, 0
         16      > JMP                                                      ->40
   12    17    >   FETCH_DIM_IS                                     ~18     !0, !1
         18        ISSET_ISEMPTY_DIM_OBJ                         0          ~18, !3
         19      > JMPZ                                                     ~19, ->24
         20    >   FETCH_DIM_R                                      ~20     !0, !1
         21        FETCH_DIM_R                                      ~21     ~20, !3
         22        QM_ASSIGN                                        ~22     ~21
         23      > JMP                                                      ->25
         24    >   QM_ASSIGN                                        ~22     0
         25    >   ADD                                              ~23     !1, 1
         26        FETCH_DIM_IS                                     ~24     !0, ~23
         27        ISSET_ISEMPTY_DIM_OBJ                         0          ~24, !3
         28      > JMPZ                                                     ~25, ->34
         29    >   ADD                                              ~26     !1, 1
         30        FETCH_DIM_R                                      ~27     !0, ~26
         31        FETCH_DIM_R                                      ~28     ~27, !3
         32        QM_ASSIGN                                        ~29     ~28
         33      > JMP                                                      ->35
         34    >   QM_ASSIGN                                        ~29     0
         35    >   SUB                                              ~30     ~22, ~29
         36        FETCH_DIM_W                                      $16     !0, !1
         37        ASSIGN_DIM                                               $16, !3
         38        OP_DATA                                                  ~30
   11    39        PRE_INC                                                  !3
         40    >   IS_SMALLER                                               !3, !2
         41      > JMPNZ                                                    ~32, ->17
    9    42    >   PRE_DEC                                                  !1
         43    >   IS_SMALLER_OR_EQUAL                                      0, !1
         44      > JMPNZ                                                    ~34, ->5
   16    45    >   INIT_FCALL                                               'var_export'
         46        SEND_VAR                                                 !0
         47        DO_ICALL                                                 
         48      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
184.43 ms | 948 KiB | 18 Q