note 16391 added to function.nl2br
| From: | rhbwebpages at hotmail dot com | Date: | Sat, 27 Oct 2001 20:03:13 +0000 |
| Subject: | note 16391 added to function.nl2br | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-19508@lists.php.net to get a copy of this message | ||
Similar to nl2br(), I use the following function to preserve multiple spaces when displaying
user-supplied data as HTML.
function sp2nbsp ($string)
{
return str_replace(" ", " ", $string);
}
It preserves the right number of spaces in such output by replacing multiple spaces with
" " codes. It might be a nice addition to the PHP functions to complement
nl2br(), if one like this doesn't already exist. I couldn't find one, at least.
(Note that there should be two spaces as the first argument to str_replace. You'd be able to
see that if this "note" software used something like sp2nbsp(). ;-)
--
http://www.php.net/manual/en/function.nl2br.php
http://master.php.net/manage/user-notes.php?action=edit+16391
http://master.php.net/manage/user-notes.php?action=delete+16391
http://master.php.net/manage/user-notes.php?action=reject+16391