This is kind of odd to me... i just been playing around with some code and in the following code it wont break lines when i use the \n... but it will do it with <BR>
Im confused why thsi doesnt work when i use it.. yet ive seen it work in previous scripts, and they use it througouth the PHP Manual/Documentation on the PHP website...
This is not a PHP issue, but it's related to HTML and to your browser. Use <pre> and </pre> -tags of HTML to define pre-formatted content - this way your browser will output the contents between those tags "properly".
If you output your $string with "\n" -newlines into a file and open it with some editor, you'll see that newlines work. Or, you can view the page source in your browser to see that \n does actually work
PHP Code:
echo "<pre>";
foreach ($states as $state) {
echo "The State is $state \n";
}
print $states['IN'];
echo "</pre>";
the \n produces a line break but you cant see line breaks on an HTML page (unless you view the source) thus use a function such as nl2br which will add a <br> tag whenever there is one!
__________________ Alexa Share <-- Trade virtual shares in websites with this online game.
codR.us <-- Submit and vote for your favorite code snippets with codR.us.
well im using "PHP Expert Editor" and then using the "RUN" command, i just assumed it would output it correctly... Okay well i used the <PRE> tags and those work perfectly, and will save me some typing in the future... thanks for the info guys... This was just one of those things i couldnt seem to grasp, prolly seemed liek a dumb question to most of you whose been programming awhile, but im newbie and want all the insight i can get.. :-)