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($cow); 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/6eZ0A
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 = $cow, !14 = $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                                       $21     !0, ->27
          7    > > FE_FETCH_R                                       ~22     $21, !6, ->27
          8    >   ASSIGN                                                   !7, ~22
   21     9        INIT_FCALL                                               'array_sum'
         10        SEND_VAR                                                 !6
         11        DO_ICALL                                         $24     
         12        ASSIGN                                                   !8, $24
   23    13        IS_SMALLER                                               !1, !8
         14      > JMPZ                                                     ~26, ->18
   24    15    >   ASSIGN                                                   !1, !8
   25    16        ADD                                              ~28     !7, 1
         17        ASSIGN                                                   !3, ~28
   28    18    > > FE_RESET_R                                       $30     !6, ->25
         19    > > FE_FETCH_R                                       ~31     $30, !9, ->25
         20    >   ASSIGN                                                   !10, ~31
   29    21        FETCH_DIM_W                                      $33     !5, !11
         22        ASSIGN_DIM                                               $33
         23        OP_DATA                                                  !9
   28    24      > JMP                                                      ->19
         25    >   FE_FREE                                                  $30
   20    26      > JMP                                                      ->7
         27    >   FE_FREE                                                  $21
   33    28      > FE_RESET_R                                       $35     !5, ->41
         29    > > FE_FETCH_R                                       ~36     $35, !12, ->41
         30    >   ASSIGN                                                   !11, ~36
   34    31        INIT_FCALL                                               'array_sum'
         32        SEND_VAR                                                 !13
         33        DO_ICALL                                         $38     
         34        ASSIGN                                                   !8, $38
   36    35        IS_SMALLER                                               !2, !8
         36      > JMPZ                                                     ~40, ->40
   37    37    >   ASSIGN                                                   !2, !8
   38    38        ADD                                              ~42     !11, 1
         39        ASSIGN                                                   !14, ~42
   33    40    > > JMP                                                      ->29
         41    >   FE_FREE                                                  $35
   42    42        ROPE_INIT                                     5  ~45     'Max+row+is+'
         43        ROPE_ADD                                      1  ~45     ~45, !3
         44        ROPE_ADD                                      2  ~45     ~45, '+with+'
         45        ROPE_ADD                                      3  ~45     ~45, !1
         46        ROPE_END                                      4  ~44     ~45, '+sum'
         47        ECHO                                                     ~44
   43    48        ROPE_INIT                                     5  ~49     'Max+col+is+'
         49        ROPE_ADD                                      1  ~49     ~49, !4
         50        ROPE_ADD                                      2  ~49     ~49, '+with+'
         51        ROPE_ADD                                      3  ~49     ~49, !2
         52        ROPE_END                                      4  ~48     ~49, '+sum'
         53        ECHO                                                     ~48
         54      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
178.86 ms | 1404 KiB | 15 Q