0

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?

7
  • 1
    If you dont want it to create new lines why do you have echo '<br>'? Commented Mar 16, 2013 at 2:03
  • Why are you applying the CSS to the H3 when that's what's wrapping all the block-level content within it? Further, you're explicitly putting a line-break after each $i loop... I'm completely lost on what you're trying to do. Commented Mar 16, 2013 at 2:03
  • I want the two echos inside the loops to be joined as one line.... Commented Mar 16, 2013 at 2:04
  • Just a side not, ids must be unique. Commented Mar 16, 2013 at 2:13
  • @DreamEater .... I cudn't get u...? Commented Mar 16, 2013 at 2:15

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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>';

2 Comments

I need slothead to be at first. e.g [slothead][slot][slot][slot][slot]<br> [slothead][slot][slot][slot][slot]
Edited and moved the <br /> outside of the loops. What kind of output are you expecting? (Where should the <br />s be?)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.