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. :)