Fill PHP table randomly with array
<p>I'm stuck with some problem - can't fill my table with random values from array. Can someone help?</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?php
header('Content-Type: text/html; charset=utf-8');
?&gt;

&lt;form action="table2.php" method="POST"&gt;
&lt;p&gt;N: &lt;input name = "row"; maxlength="2" size="1" value="5"&gt;&lt;/p&gt;
&lt;p&gt;M: &lt;input name = "col"; maxlength="2" size="1" value="7"&gt;&lt;/p&gt;
    &lt;input type="submit" name="zero" value="go"/&gt;
&lt;/form&gt;
&lt;?php

$array1 = array("1", "2", "3", "4", "5", "6", "7", "8");
$rand_keys = array_rand($array1, 2);
echo $array1[$rand_keys[0]] . "\n";
function draw_table($row,$col) {
    $table = "&lt;table&gt;";
    $i = 1;
    do {
        $table .= "&lt;tr&gt;";
        $j = 1;
        do {
            $table .= "&lt;td&gt;X  $i Y  $j";
            $table .= "&lt;/td&gt;";
            $j++;
        }
        while($j &lt;= $col);
        $table .= "&lt;/tr&gt;";
        $i++;
    }
    while($i &lt;= $row);
    $table .= "&lt;/table&gt;";
    return $table;
}

if(isset($_POST['zero'])) {
    $rows = $_POST['row']; 
    $cols = $_POST['col']; 
    
    echo(draw_table($rows, $cols));
}
?&gt;</code></pre>
</div>
</div>
</p>

<p>I tried to use array_rand, but can't understand how modify this code for that function</p>

<pre><code>$table .= "&lt;td&gt;X  $i Y  $j";
$table .= "&lt;/td&gt;";
$j++;
</code></pre>