dimanche 2 juillet 2017

Generate a random number table using PHP

When the page is refreshed, an random length array between 1 and 30 is generated (index). Another random array is generated between 0 and 100 (value). It randomly generates value fine but not index. Is there something I might be missing in the index foreach loop. Here is a couple of images of what is should be output 1 and output2

<?php $index = range(1, 25);
shuffle($index);
$value = range(0, 100);
shuffle($value); ?>
    <table>
        <th>Index</th>
        <th>Value</th>
        <tr>
            <td>
                <?php foreach ($index as $indexes) {
                echo $indexes.'</br>';
                } ?>
            </td>
            <td>
                <?php foreach ($value as $values) {
                echo $values.'</br>';
                } ?>
            </td>
        </tr>
    </table>




Aucun commentaire:

Enregistrer un commentaire