Q:

Can't print 9x9 table correctly

The code is giving first 10 numbers in first row and 9 numbers in other 7 rows and 8 numbers in last row.
How can I obtain the 9x9 matrix so that all the rows have 9 numbers? 
I have tried everything, but nothing works. Is there any way to do this?
<table border=1>
    <tr>
    <?php

        for ($i = 1; $i < 82; $i++) {
            $arr[] = $i;
        }

        for ($i = 0; $i < 81; $i++) {
            echo '<td>' . $arr[$i] . '</td>';

        if ($i % 9 == 0 && $i != 0) {
            echo "</tr><tr>";
        }

        }

    ?>
    </tr>
</table>

A:

The best is what @Rizier says, but if you want to modify only your code then:-
<table border=1>
    <tr>
    <?php
    for ($i = 1; $i < 82; $i++) {
    $arr[] = $i;
}
    $j=1; //add a new count starts from 1
    for ($i=0; $i<81; $i++)
    {
        echo '<td>'.$arr[$i].'</td>';

        if ($j%9==0)  // check counter modules 9 will be zero or not. it will break after each 9 iteration.
        {
           echo "</tr><tr>";
        }

    $j++;} // increase the value of counter
    ?>
    </tr>
</table>

Output:-http://prntscr.com/7bu34m

