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
https://forums.phpfreaks.com/topic/167481-for-each-output-question/
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.

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.