I am trying to generate a table with php for loop, that lists numbers. Something like this:
1 | 2 | 3 | 4 | 5
2 | 3 | 4 | 5 | 1
3 | 4 | 5 | 1 | 2
4 | 5 | 1 | 2 | 3
5 | 1 | 2 | 3 | 4
I still have problems getting it, this is actually quite simple, but I have not been able to solve it. So far I have the following code:
<?php
echo "<table border='1'><br />";
for ($row = 0; $row < 5; $row ++) {
echo "<tr>";
for ($col = 1; $col <= 4; $col ++) {
echo "<td>", ($col + ($row * 4)), "</td>";
}
echo "</tr>";
}
echo "</table>";
?>
However, this only generates the following:
1 | 2 | 3 | 4
5 | 6 | 7 | 8
9 | 10 | 11 | 12
13 | 14 | 15 | 16
17 | 18 | 19 | 20
Thank you, any help would be appreciated!
$a = array(1,2,3,4,5); array_unshift($a, array_pop($a));