PHP 5x5 table with numbers in them

I am a beginner in PHP and I have the following problem, I need to create a 5x5 table in PHP like this: http://shrani.si/f/3p/5W/4BNOssVD/5x5matrix.jpg

This is what I have so far:

echo '<table border="1" style="width:100px">';
    for ($i=0; $i < 5; $i++) {      
        echo "<tr>";
            for ($j=0; $j < 5; $j++) { 
                echo "<td>";                
                    echo $j;
                echo "</td>";
                }
        echo "</tr>";
    }
echo "</table>";

      

+3


source to share


1 answer


Change echo $j;

to:



echo ($i*5) + $j + 1;

      

+3


source







All Articles