On Wed, Jan 28, 2009 at 12:05:34PM -0700, Don Collier wrote: > I am just learning PHP from the O'Reilly "Learning PHP 5" book and I > have a question regarding the formatting of text. Actually it is a > couple of questions. > > First, when I use the \n and run the script from the command line it > works great. When I run the same code in a browser it does not put the > newline in and the text runs together. I know that I can use <br/> to > do the same thing, but why is it this way? Browser don't break lines on the \n character. They only break on <br> or <p> tags. That's just the way it is. You can use the PHP function nl2br() to insert <br> tags where the \n characters are. > > The second question is closely related to the first. When formatting > text using printf the padding works great when running from the command > line but not at all when in a browser. Browsers don't respect multiple spaces, etc., except in between certain tags, like <pre></pre>. Instead, they combine multiple spaces into a single space and break lines where they like, based on layout. You can use the HTML character if you don't want lines or phrases to break at the whim of the browser. If you want exact layout (columns lined up, etc.), the simplest solution is to use HTML tables. Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php