Jump to content

for each () Output Question


futhermukker

Recommended Posts

Why does the output of this code:

 

foreach ($Day as $D) {
echo '<center><a style="font-size: 80pt; font-family:Arial; font-weight:bolder">'.$D.'</a></center>';
}

 

Where $Day are the days of the week (previously selected with checkboxes in my form), put each day on a seperate line.

 

Whereas this code:

 

foreach ($Day as $D) {
echo $D;
}

 

puts the results on the same line.

 

Is there any way to change the first code to place the results on the same line?

 

Here is the url of the form I am working on:

 

www.yardmartplus.com/sign.php

 

Please be kind I am new to php and sort of winging this.  :D

 

 

 

Link to comment
Share on other sites

the reason is because when you close the center tag, it automatically forces the subsequent content to go onto a new line - it doesn't make sense for the content to left-align on the same line as the centered one, as you may get overlap and the content wouldn't be in the proper order.

Link to comment
Share on other sites

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.