3v4l.org

run code in 300+ PHP versions simultaneously
<?php //да се намерят реда и колоната с най-голяма стойност $arr = [ [1, 4, 7,10], [2, 5, 8,11], [3, 6, 9,12], [13,14,15,16] ]; $maxRow = 0; $maxCol = 0; $fromMaxRow = 0; $fromMaxCol = 0; $cols = []; foreach($arr as $keyRow => $row) { $sum = array_sum($row); if($maxRow < $sum) { $maxRow = $sum; $fromMaxRow = $keyRow + 1; } foreach($row as $keyCell => $cell) { $cols[$key][] = $cell; } } foreach ($cols as $key => $col) { $sum = array_sum($col); if($maxCol < $sum) { $maxCol = $sum; $fromMaxCow = $key + 1; } } echo "Max row is $fromMaxRow with $maxRow sum"; echo "Max col is $fromMaxCol with $maxCol sum";
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 27
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 27
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 18
Branch analysis from position: 15
2 jumps found. (Code = 77) Position 1 = 19, Position 2 = 25
Branch analysis from position: 19
2 jumps found. (Code = 78) Position 1 = 20, Position 2 = 25
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 25
Branch analysis from position: 18
Branch analysis from position: 27
2 jumps found. (Code = 77) Position 1 = 29, Position 2 = 41
Branch analysis from position: 29
2 jumps found. (Code = 78) Position 1 = 30, Position 2 = 41
Branch analysis from position: 30
2 jumps found. (Code = 43) Position 1 = 37, Position 2 = 40
Branch analysis from position: 37
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
Branch analysis from position: 40
Branch analysis from position: 41
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 41
Branch analysis from position: 27
filename:       /in/Yrbl2
function name:  (null)
number of ops:  55
compiled vars:  !0 = $arr, !1 = $maxRow, !2 = $maxCol, !3 = $fromMaxRow, !4 = $fromMaxCol, !5 = $cols, !6 = $row, !7 = $keyRow, !8 = $sum, !9 = $cell, !10 = $keyCell, !11 = $key, !12 = $col, !13 = $fromMaxCow
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   ASSIGN                                                   !0, <array>
   12     1        ASSIGN                                                   !1, 0
   13     2        ASSIGN                                                   !2, 0
   15     3        ASSIGN                                                   !3, 0
   16     4        ASSIGN                                                   !4, 0
   18     5        ASSIGN                                                   !5, <array>
   20     6      > FE_RESET_R                                       $20     !0, ->27
          7    > > FE_FETCH_R                                       ~21     $20, !6, ->27
          8    >   ASSIGN                                                   !7, ~21
   21     9        INIT_FCALL                                               'array_sum'
         10        SEND_VAR                                                 !6
         11        DO_ICALL                                         $23     
         12        ASSIGN                                                   !8, $23
   23    13        IS_SMALLER                                               !1, !8
         14      > JMPZ                                                     ~25, ->18
   24    15    >   ASSIGN                                                   !1, !8
   25    16        ADD                                              ~27     !7, 1
         17        ASSIGN                                                   !3, ~27
   28    18    > > FE_RESET_R                                       $29     !6, ->25
         19    > > FE_FETCH_R                                       ~30     $29, !9, ->25
         20    >   ASSIGN                                                   !10, ~30
   29    21        FETCH_DIM_W                                      $32     !5, !11
         22        ASSIGN_DIM                                               $32
         23        OP_DATA                                                  !9
   28    24      > JMP                                                      ->19
         25    >   FE_FREE                                                  $29
   20    26      > JMP                                                      ->7
         27    >   FE_FREE                                                  $20
   33    28      > FE_RESET_R                                       $34     !5, ->41
         29    > > FE_FETCH_R                                       ~35     $34, !12, ->41
         30    >   ASSIGN                                                   !11, ~35
   34    31        INIT_FCALL                                               'array_sum'
         32        SEND_VAR                                                 !12
         33        DO_ICALL                                         $37     
         34        ASSIGN                                                   !8, $37
   36    35        IS_SMALLER                                               !2, !8
         36      > JMPZ                                                     ~39, ->40
   37    37    >   ASSIGN                                                   !2, !8
   38    38        ADD                                              ~41     !11, 1
         39        ASSIGN                                                   !13, ~41
   33    40    > > JMP                                                      ->29
         41    >   FE_FREE                                                  $34
   42    42        ROPE_INIT                                     5  ~44     'Max+row+is+'
         43        ROPE_ADD                                      1  ~44     ~44, !3
         44        ROPE_ADD                                      2  ~44     ~44, '+with+'
         45        ROPE_ADD                                      3  ~44     ~44, !1
         46        ROPE_END                                      4  ~43     ~44, '+sum'
         47        ECHO                                                     ~43
   43    48        ROPE_INIT                                     5  ~48     'Max+col+is+'
         49        ROPE_ADD                                      1  ~48     ~48, !4
         50        ROPE_ADD                                      2  ~48     ~48, '+with+'
         51        ROPE_ADD                                      3  ~48     ~48, !2
         52        ROPE_END                                      4  ~47     ~48, '+sum'
         53        ECHO                                                     ~47
         54      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
178.68 ms | 1400 KiB | 15 Q