note 30125 added to function.chr
| From: | Kristin at rack1 dot php dot net | Date: | Fri, 07 Mar 2003 02:19:11 +0000 |
| Subject: | note 30125 added to function.chr | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-44965@lists.php.net to get a copy of this message | ||
Note that chr(10) is a 'line feed' and chr(13) is a 'carriage return' and they
are not the same thing! I found this out while attempting to parse text from forms and text files
for inclusion as HTML by replacing all the carriage returns with <BR>'s only to find
after many head-scratchings that I should have been looking for line feeds. If anyone can shed some
light on what the difference is, please do.
If you're planning on saving text from a form into a database for later display, you'll
need to apply the following function so that it gets saved with the proper HTML tags.
$text = str_replace ( chr(10), "<BR>", $text );
When you want to plug it back into that form for editing you need to convert it back.
$text = str_replace ( "<BR>", chr(10), $text)
Hope this saves somebody some trouble. :)
--
http://www.php.net/manual/en/function.chr.php
http://master.php.net/manage/user-notes.php?action=edit+30125
http://master.php.net/manage/user-notes.php?action=delete+30125
http://master.php.net/manage/user-notes.php?action=reject+30125