SirChick Posted October 17, 2007 Share Posted October 17, 2007 I have a question about while loops and echo'n the result. Say you have to have: Hello Hello Hello How can you "while" Do soemtihng like that so that the first hello is above the second but the 3rd one is under the second but also to the far right ? Quote Link to comment https://forums.phpfreaks.com/topic/73684-curious-question-about-while-loops/ Share on other sites More sharing options...
BlueSkyIS Posted October 17, 2007 Share Posted October 17, 2007 html or plain text? either way, its about the same, but whether you use HTML line breaks. Quote Link to comment https://forums.phpfreaks.com/topic/73684-curious-question-about-while-loops/#findComment-371741 Share on other sites More sharing options...
SirChick Posted October 17, 2007 Author Share Posted October 17, 2007 no cos line breaks doesn't make the 3rd output of the while loop go to the right =/ Like say i had: while $cheese > 1 do: Echo hello echo hello echo hello but that 3rd one ^ needs to be further to the right... Quote Link to comment https://forums.phpfreaks.com/topic/73684-curious-question-about-while-loops/#findComment-371745 Share on other sites More sharing options...
Orio Posted October 17, 2007 Share Posted October 17, 2007 I don't understand your question... Why would you want to do something like that in a loop? If you had a pattern here I would have understood, but there's no actual pattern. You could solve it with if's of course... <?php $i = 0; while($i<3) { if($i == 2) echo " Hello"; else echo "Hello<br>"; $i++; } ?> Orio. Quote Link to comment https://forums.phpfreaks.com/topic/73684-curious-question-about-while-loops/#findComment-371746 Share on other sites More sharing options...
BlueSkyIS Posted October 17, 2007 Share Posted October 17, 2007 echo " hello"; Quote Link to comment https://forums.phpfreaks.com/topic/73684-curious-question-about-while-loops/#findComment-371747 Share on other sites More sharing options...
SirChick Posted October 17, 2007 Author Share Posted October 17, 2007 well it was merely an example cos the messages it loads will not just be one under each other some will be to the right and the left.. and i did not know how to do that using a while loop and because there could be many amounts of messages i cant phyiscally hard code in where to echo stuff because if there was more than say 5 and i only put in 4 echo's the 5th one would not appear. Try to imagine that the 3rd hello doesnt have spaces, its just in a fixed position on the page. Quote Link to comment https://forums.phpfreaks.com/topic/73684-curious-question-about-while-loops/#findComment-371750 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.