BigCanadian Posted November 22, 2006 Share Posted November 22, 2006 This is the code Im testing <?phpfor ($i = 1; $i < 3; $i = $i + 1) { for ($j = 1; $j < 4; $j = $j + 1) { for ($k = 1; $k < 3; $k = $k + 1) { print "I: $i, J: $j, K: $k\n"; } }}?>and it says it will output thisI: 1, J: 1, K: 1I: 1, J: 1, K: 2I: 1, J: 2, K: 1I: 1, J: 2, K: 2I: 2, J: 1, K: 1I: 2, J: 1, K: 2I: 2, J: 2, K: 1I: 2, J: 2, K: 2but instead it gives me this I: 1, J: 1, K: 1 I: 1, J: 1, K: 2 I: 1, J: 2, K: 1 I: 1, J: 2, K: 2 I: 1, J: 3, K: 1 I: 1, J: 3, K: 2 I: 2, J: 1, K: 1 I: 2, J: 1, K: 2 I: 2, J: 2, K: 1 I: 2, J: 2, K: 2 I: 2, J: 3, K: 1 I: 2, J: 3, K: 2help please as to why the \n is not working Link to comment https://forums.phpfreaks.com/topic/28054-doing-a-tutorial-but-n-isnt-working/ Share on other sites More sharing options...
Massacres Posted November 22, 2006 Share Posted November 22, 2006 I just had a similar problem. If you view the source code it will display what its supposed to, but it doesn't. The browser reads \n as whitespace. You have to use <br> instead.[code]<?phpfor ($i = 1; $i < 3; $i = $i + 1) { for ($j = 1; $j < 4; $j = $j + 1) { for ($k = 1; $k < 3; $k = $k + 1) { print "I: $i, J: $j, K: $k<br>"; } }}?>[/code] Link to comment https://forums.phpfreaks.com/topic/28054-doing-a-tutorial-but-n-isnt-working/#findComment-128338 Share on other sites More sharing options...
BigCanadian Posted November 22, 2006 Author Share Posted November 22, 2006 ohhhh swell..... but can anyone tell me why php wont work and html will work? also will that work if we use xhtml? (such as <br />)?? Link to comment https://forums.phpfreaks.com/topic/28054-doing-a-tutorial-but-n-isnt-working/#findComment-128344 Share on other sites More sharing options...
Massacres Posted November 22, 2006 Share Posted November 22, 2006 \n is counted as whitespace so your browser parses it out.Your browser does the bidding of html :o Link to comment https://forums.phpfreaks.com/topic/28054-doing-a-tutorial-but-n-isnt-working/#findComment-128352 Share on other sites More sharing options...
trq Posted November 22, 2006 Share Posted November 22, 2006 php outputs strings, its upto the broswer to parse the html. Not everyone uses php to make webpages you know? I haven't made anything web related in over 18 months and I still use php nearly everyday. Link to comment https://forums.phpfreaks.com/topic/28054-doing-a-tutorial-but-n-isnt-working/#findComment-128366 Share on other sites More sharing options...
BigCanadian Posted November 22, 2006 Author Share Posted November 22, 2006 wow this language is vast eh... oh well... I really hope if I dedicate my time to it Ill understand it haha... I think my main problem will be understanding how MySql databases work.. ohhh well I spose Ill just keep reading these tutorial you showed me thorpe.I gotta say they are much clearer than the other ones on php.net... but that example (the one I posted above) with all those nested things really confused meIn my mind it keeps computing like it should count each variable up to the designated amount... for example 3 for $i and 4 for $j... etc will this come easier to me later or am I doomed to not see this connection... I mean if you were to nest a whole bunhc of tables and row frame and columns in front of me I could tell you in no time what it would look like... will php get this way for me? I know its kind of a rhetorical question... but any assurance (even if its false rhetorical assurance) is better than nothing hahah. thanks again for the help guys!Biggie C Link to comment https://forums.phpfreaks.com/topic/28054-doing-a-tutorial-but-n-isnt-working/#findComment-128370 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.