Question

Here is my code segment:

for($i=0;$i<23;$i++){
    echo "<div id=slotshead></div>";
    for($j=0;$j<30;$j++) {
        echo " <div id=slots></div>";
    }
    echo '<br>';
}

But, it doesn't work. I want the two echo statements inside the loop to be continued, not break into a new line. How can I fix it?

Was it helpful?

Solution

If you just want to have each looped output display in a single line, you were nearly there.

Add the following to CSS; and you're done.

h3 > div {
    display: inline-block;
}

It'll generate the output as this fiddle.

OTHER TIPS

If I understand what you're asking... this will combine your loops:

 for ($i = 0; $i < 23; $i++) {
   echo "<div id=slotshead></div>";
   for ($j = 0; $j < 30; $j++) {
     echo " <div id=slots></div>";
   }
 }
 echo '<br>';
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top