<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="stylesheet.css">
<meta charset="utf-8">
</head>
<body>
<?php
$array = array();
echo "<table>";
for ($z=0; $z <=9; $z++)
{
echo "<tr>";
for ($s=0; $s <=9; $s++)
{
$r = mt_rand (1, 100);
array_push ($array, $r);
if ($r %2 != 0)
{
echo "<td bgcolor = red>";
echo $r;
echo "</td>";
}
else
{
echo "<td bgcolor= lightgreen>";
echo $r;
echo "</td>";
}
}
echo "</tr>";
}
echo "</table>";
echo "<br>";
echo "<table>";
sort($array);
$arraysplit = array_chunk($array, count($array)/10);
for ($z=0; $z <=9; $z++)
{
echo "<tr>";
for ($s=0; $s <=9; $s++)
{
if ($r %2 != 0)
{
echo "<td bgcolor = red>";
echo json_encode (arraysplit);
echo "</td>";
}
else
{
echo "<td bgcolor= lightgreen>";
echo json_encode ($arraysplit);
echo "</td>";
}
}
echo "</tr>";
}
?>
</body>
</html>
Hey absolute beginner here.
Im working on a table that gives random numbers out and then colorizes them if they can be devided by 2. That works fine.
Now i want to get those randomly generated numbers into a second table but sorted. I already managed to put the numbers i generated into an array and sort it but i cant figure out how to echo them 1 by 1 into the table. Maybe you can help me out.