Задача 2 - PHP Online
Form of PHP Sandbox
Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php
in the places where the PHP script should be executed.
Result of php executing
Full code of Задача 2.php
- <?php
- $numbers = range(1, 1000);
- shuffle($numbers);
- $chunkedNumbers = array_chunk($numbers, 5);
- $result = array_splice($chunkedNumbers, 0, 7);
- foreach ($result as $row) {
- foreach($row as $el) {
- echo $el . " ";
- }
- echo "\n";
- }
- $columnsSums = [];
- for ($i=0;$i<=4;$i++) {
- $columnsSums[$i] = array_sum(array_column($result, $i));
- }
- echo "\nСуммы по столбцам: ";
- print_r(implode(' ', $columnsSums));
- $rowsSums = [];
- foreach($result as $row) {
- $rowsSums[] = array_sum($row);
- }
- echo "\nСуммы по строкам: ";
- print_r(implode(' ', $rowsSums));
File Description
- Задача 2
- PHP Code
- 26 Aug-2022
- 594 Bytes
You can Share it:
Latest PHP Pastes