Search code examples
phplineechonested-loopscontinuation

PHP nested loop echos must not break into new line


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?


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.