Hi! Could we please enable some services and cookies to improve your experience and our website?

PHPize Online / SQLize Online  /  SQLtest Online

A A A
Login    Share code      Blog   FAQ

Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code

Copy Format Clear

Stuck with a problem? Got Error? Ask AI support!

Copy Clear
Copy Format Clear
<?php $row = 5; $cell = 7; $numArray = range(1, 1000); shuffle($numArray); $length = $cell * $row; $matrix = array_slice($numArray, 0, $length); $matrix = array_chunk($matrix, $cell); $lineArray = array_fill(1, $cell, " "); $firstString = implode(" | ", $lineArray); echo " | $firstString | summ\n"; foreach ($matrix as $matrixRow) { $preparedMatrixRow = array_map(function($number){ return sprintf("%' 4d", $number); }, $matrixRow); $rowString = implode(" | ", $preparedMatrixRow); $rowSumm = array_sum($matrixRow); echo " | $rowString | $rowSumm\n"; } echo " summ | $firstString | \n";
Copy Clear