note 30125 modified in function.chr by vrana
| From: | vrana@php.net | Date: | Tue, 17 Aug 2004 14:54:48 +0000 |
| Subject: | note 30125 modified in function.chr by vrana | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-80024@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.
<?php
$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.
<?php
$text = str_replace ( "<BR>", chr(10), $text)
?>
Hope this saves somebody some trouble. :)
--was--
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://php.net/manual/en/function.chr.php