- Joined
- Jul 26, 2006
- Messages
- 3,626
- Reaction score
- 1,006
Say I have:
And in the same file, somewhere in the body (location is unimportant).
The generated HTML code will look like this:
I hate how this looks. Is there any ("clean") way in which to preserve the whitespace in front of the different senteces in the paragraph, so as to make it look like this:
I know I can do this:
But that looks ugly as ****. Suggestions?
Note that this is just about sematics/looks; not functionality - there is virtually no visible difference in the code until you start reading the page's source. I just want my source code to be easily legible - proper indentation and such.
Thanks!
PHP:
$string = "Hello, user!\n".
= "How are you today?\n".
= "Here's today's news:";
And in the same file, somewhere in the body (location is unimportant).
Code:
<div class="foo">
<p><?=nl2br($string);?></p>
</div>
The generated HTML code will look like this:
Code:
<div class="foo">
<p>Hello, user!<br />
How are you today?<br />
Here's today's news:</p>
</div>
I hate how this looks. Is there any ("clean") way in which to preserve the whitespace in front of the different senteces in the paragraph, so as to make it look like this:
Code:
<div class="foo">
<p>Hello, user!<br />
How are you today?<br />
Here's today's news:</p>
</div>
I know I can do this:
PHP:
$string = "Hello, user!\n".
= " How are you today?\n".
= " Here's today's news:";
But that looks ugly as ****. Suggestions?
Note that this is just about sematics/looks; not functionality - there is virtually no visible difference in the code until you start reading the page's source. I just want my source code to be easily legible - proper indentation and such.
Thanks!

