I am trying to use a modulo to make all even numbers replaced with a star and all odds replaced with a percent sign... this is my code:
<?php
$x=0;
$min=900;
$max=2000;
// initialize array of random values
$random_array = array();
// initialize temporary array for sorting
$temp_array = array();
// start html table for random values
echo "<table border=\"1\">";
// create $random_array with random numbers, display html table rows and
// store each value in onedimensional $temp_array for sorting
for($row=1;$row<=20; $row++){
echo "<tr>\n";
for($col=1;$col<=20; $col++) {
$x=rand($min,$max);
$random_array[$row][$col] = $x;
echo"<td>$x</td>\n";
// add value to the $temp_array
$temp_array[] = $x;
}
echo "</tr>";
}
// end the html table
echo "</table>";
// sort the $temp_array (sort works on onedimensional arrays)
sort($temp_array);
// start a table for sorted values
echo "<table border=\"1\">";
// initialize counter that will be the $temp_array's key
$key = 0;
// display html table rows of sorted values
for($row=1;$row<=20; $row++){
echo "<tr>\n";
for($col=1;$col<=20; $col++) {
echo"<td>{$temp_array[$key]}</td>\n";
// increase the key
$key++;
}
echo "</tr>";
}
// end the html table of sorted values
echo "</table>";
// sort the $temp_array (sort works on onedimensional arrays)
rsort($temp_array);
// start a table for sorted values
echo "<table border=\"1\">";
// initialize counter that will be the $temp_array's key
$key = 0;
// display html table rows of sorted values
for($row=1;$row<=20; $row++){
echo "<tr>\n";
for($col=1;$col<=20; $col++) {
echo"<td>{$temp_array[$key]}</td>\n";
// increase the key
$key++;
}
echo "</tr>";
}
// end the html table of sorted values
echo "</table>";
?>
I need to make another table for the use of the modulo so it doesn't affect the other tables? Can anyone help? I can verify further if needed!
Thanks and respond a.s.a.p!
Sedique