jacobmott Posted March 10, 2009 Share Posted March 10, 2009 So, yeah ummmm.... why is for ($i = 0;$i < 10; $i++){ echo "$i\n"; } not printing 0 1 2 3 4 5 6 7 8 9 to the screen but printing 0123456789 instead? Quote Link to comment https://forums.phpfreaks.com/topic/148800-solved-echo-and-newline/ Share on other sites More sharing options...
aebstract Posted March 10, 2009 Share Posted March 10, 2009 \n will put a new line in the code, not in the actual output. You'll have to use something like <br /> to do that. Quote Link to comment https://forums.phpfreaks.com/topic/148800-solved-echo-and-newline/#findComment-781346 Share on other sites More sharing options...
jacobmott Posted March 10, 2009 Author Share Posted March 10, 2009 Thanks for the response. ok for ($i = 0;$i < 10; $i++){ echo $i; <br /> } For some reason the parser is interpreting <br /> literally into Break the page. lol Because when I use this syntax my page will not display. Quote Link to comment https://forums.phpfreaks.com/topic/148800-solved-echo-and-newline/#findComment-781355 Share on other sites More sharing options...
JonnoTheDev Posted March 10, 2009 Share Posted March 10, 2009 echo $i."<br />"; Quote Link to comment https://forums.phpfreaks.com/topic/148800-solved-echo-and-newline/#findComment-781356 Share on other sites More sharing options...
aebstract Posted March 10, 2009 Share Posted March 10, 2009 Yeah you're putting the br outside of your ; You would either have to close your php tags ?> <br /> <?php which I don't think is that practical, personally. Or something like neil suggested: for ($i = 0;$i < 10; $i++){ echo $i <br />; } Really just need to move your ; to the end of the line. Quote Link to comment https://forums.phpfreaks.com/topic/148800-solved-echo-and-newline/#findComment-781359 Share on other sites More sharing options...
jacobmott Posted March 10, 2009 Author Share Posted March 10, 2009 Awesome. Thank you much. Works like a charm. Quote Link to comment https://forums.phpfreaks.com/topic/148800-solved-echo-and-newline/#findComment-781361 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.