List horizontally data from array

Issue

enter image description here

This is the result I’ve got. But I wan to display it horizontally. Can anyone help me?
Here’s my code:

<?php
for($j = 0; $j < count($sub); $j++){
     echo "
        <table class='table'>
            <thead>
                <tr>
                    <th scope='col'>" . $sub[$j] . "</th>
                </tr>
             </thead>
        </table>";
}?>

Solution

Your subjects should be ths in one tr:

echo "<table class='table'><thead><tr>";
for($j = 0; $j < count($sub); $j++){
    echo "<th scope='col'>" . $sub[$j] . "</th>";
}
echo "</tr></thead></table>";

Fiddle here.

Answered By – u_mulder

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published