PDA

Click to See Complete Forum and Search --> : displaying messages...


abhilashdas
Jun 22nd, 2006, 02:21 AM
Just as the function nl2br() , is there any function to handle the conversion of tab to html counterpart? (Or performs both).
:wave:

john tindell
Jun 22nd, 2006, 06:57 AM
check out htmlentities() (http://uk2.php.net/manual/en/function.htmlentities.php) but i think you would have to manually convert tabs to four  's.

mendhak
Jun 22nd, 2006, 08:01 AM
Tabs don't exist in HTML. If you need to indent just one line, use four &nbsp;s. If it's an entire paragraph, you might want to surround it in <blockquote>

penagate
Jun 22nd, 2006, 10:05 AM
UAs ignore whitespace by default, unless you explicity say otherwise (using the CSS white-space property, or the <pre> tag which does that by default). Using non breaking spaces (&nbsp;) is not a good idea unless they really shouldn't be non-breaking spaces, i.e. a section of text should be displayed on one line.

If you need to indent text, use the text-indent property (for the first line of a paragraph) or the margin property (for the whole paragraph). You're using <p> tags? Good.

abhilashdas
Jun 23rd, 2006, 05:57 AM
Whts the exact procedure for displaying messages stored in a database?. Curently I am able to do this, But I need to display thr message exactly as enterd by the user keeping newline and spaces in place. With nl2br I have managed to handle newlines but the tab and white spaces are still a problem!!!.

Any shortcuts, other than checking for whitespaces manually?

penagate
Jun 23rd, 2006, 06:59 AM
Use white-space:pre like I suggested.

<p class="message">
<?=$message?>
</p>


.message {
white-space: pre;
}

abhilashdas
Jun 25th, 2006, 11:54 PM
Thanks for the reply.