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 \n"; echo "Max col is $fromMaxCol with $maxCol sum \n";
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
Warning: Undefined variable $key in /in/Ke9bN on line 29 Warning: Undefined variable $key in /in/Ke9bN on line 29 Warning: Undefined variable $key in /in/Ke9bN on line 29 Warning: Undefined variable $key in /in/Ke9bN on line 29 Warning: Undefined variable $key in /in/Ke9bN on line 29 Warning: Undefined variable $key in /in/Ke9bN on line 29 Warning: Undefined variable $key in /in/Ke9bN on line 29 Warning: Undefined variable $key in /in/Ke9bN on line 29 Warning: Undefined variable $key in /in/Ke9bN on line 29 Warning: Undefined variable $key in /in/Ke9bN on line 29 Warning: Undefined variable $key in /in/Ke9bN on line 29 Warning: Undefined variable $key in /in/Ke9bN on line 29 Warning: Undefined variable $key in /in/Ke9bN on line 29 Warning: Undefined variable $key in /in/Ke9bN on line 29 Warning: Undefined variable $key in /in/Ke9bN on line 29 Warning: Undefined variable $key in /in/Ke9bN on line 29 Fatal error: Uncaught TypeError: Unsupported operand types: string + int in /in/Ke9bN:38 Stack trace: #0 {main} thrown in /in/Ke9bN on line 38
Process exited with code 255.
Output for 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 7.3.31, 7.4.0 - 7.4.33
Notice: Undefined variable: key in /in/Ke9bN on line 29 Notice: Undefined variable: key in /in/Ke9bN on line 29 Notice: Undefined variable: key in /in/Ke9bN on line 29 Notice: Undefined variable: key in /in/Ke9bN on line 29 Notice: Undefined variable: key in /in/Ke9bN on line 29 Notice: Undefined variable: key in /in/Ke9bN on line 29 Notice: Undefined variable: key in /in/Ke9bN on line 29 Notice: Undefined variable: key in /in/Ke9bN on line 29 Notice: Undefined variable: key in /in/Ke9bN on line 29 Notice: Undefined variable: key in /in/Ke9bN on line 29 Notice: Undefined variable: key in /in/Ke9bN on line 29 Notice: Undefined variable: key in /in/Ke9bN on line 29 Notice: Undefined variable: key in /in/Ke9bN on line 29 Notice: Undefined variable: key in /in/Ke9bN on line 29 Notice: Undefined variable: key in /in/Ke9bN on line 29 Notice: Undefined variable: key in /in/Ke9bN on line 29 Warning: A non-numeric value encountered in /in/Ke9bN on line 38 Max row is 4 with 58 sum Max col is 0 with 136 sum
Output for 7.3.32 - 7.3.33
Warning: A non-numeric value encountered in /in/Ke9bN on line 38 Max row is 4 with 58 sum Max col is 0 with 136 sum
Output for 5.5.24 - 5.5.35, 5.6.8 - 5.6.28, 7.0.0 - 7.0.20
Notice: Undefined variable: key in /in/Ke9bN on line 29 Notice: Undefined variable: key in /in/Ke9bN on line 29 Notice: Undefined variable: key in /in/Ke9bN on line 29 Notice: Undefined variable: key in /in/Ke9bN on line 29 Notice: Undefined variable: key in /in/Ke9bN on line 29 Notice: Undefined variable: key in /in/Ke9bN on line 29 Notice: Undefined variable: key in /in/Ke9bN on line 29 Notice: Undefined variable: key in /in/Ke9bN on line 29 Notice: Undefined variable: key in /in/Ke9bN on line 29 Notice: Undefined variable: key in /in/Ke9bN on line 29 Notice: Undefined variable: key in /in/Ke9bN on line 29 Notice: Undefined variable: key in /in/Ke9bN on line 29 Notice: Undefined variable: key in /in/Ke9bN on line 29 Notice: Undefined variable: key in /in/Ke9bN on line 29 Notice: Undefined variable: key in /in/Ke9bN on line 29 Notice: Undefined variable: key in /in/Ke9bN on line 29 Max row is 4 with 58 sum Max col is 0 with 136 sum

preferences:
170.51 ms | 403 KiB | 179 Q