3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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";
based on Yrbl2
Output for 7.1.0 - 7.2.0
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 5.4.9 - 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
Output for 5.3.19 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/Ke9bN on line 5
Process exited with code 255.