Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.