Jump to content

Curious question about while loops


SirChick

Recommended Posts

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 ?

Link to comment
https://forums.phpfreaks.com/topic/73684-curious-question-about-while-loops/
Share on other sites

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.

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.