futhermukker Posted July 26, 2009 Share Posted July 26, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/167481-for-each-output-question/ Share on other sites More sharing options...
vineld Posted July 26, 2009 Share Posted July 26, 2009 Create a proper html document and see if the problem remains. Quote Link to comment https://forums.phpfreaks.com/topic/167481-for-each-output-question/#findComment-883114 Share on other sites More sharing options...
futhermukker Posted July 26, 2009 Author Share Posted July 26, 2009 Not sure what you mean by that. Please elaborate. Quote Link to comment https://forums.phpfreaks.com/topic/167481-for-each-output-question/#findComment-883118 Share on other sites More sharing options...
sasa Posted July 26, 2009 Share Posted July 26, 2009 try echo '<center>'; foreach ($Day as $D) { echo '<a style="font-size: 80pt; font-family:Arial; font-weight:bolder">'.$D.'</a>'; } echo '</center>'; Quote Link to comment https://forums.phpfreaks.com/topic/167481-for-each-output-question/#findComment-883136 Share on other sites More sharing options...
futhermukker Posted July 26, 2009 Author Share Posted July 26, 2009 Worked beautifully!! Thank you. Would a brief explanation be to much to ask? I would like to know what and why. But, thank you, thank you, thank you. Quote Link to comment https://forums.phpfreaks.com/topic/167481-for-each-output-question/#findComment-883147 Share on other sites More sharing options...
akitchin Posted July 26, 2009 Share Posted July 26, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/167481-for-each-output-question/#findComment-883150 Share on other sites More sharing options...
futhermukker Posted July 26, 2009 Author Share Posted July 26, 2009 Thank you for the explanation. That is extremely helpful. Quote Link to comment https://forums.phpfreaks.com/topic/167481-for-each-output-question/#findComment-883153 Share on other sites More sharing options...
trq Posted July 26, 2009 Share Posted July 26, 2009 Its worth mentioning too (because you seem oblivious to it) that the formatting of your output is done with html. PHP does nothing here but out html strings. Quote Link to comment https://forums.phpfreaks.com/topic/167481-for-each-output-question/#findComment-883159 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.