note 40995 deleted from function.chr by danbrown
| From: | danbrown@php.net | Date: | Wed, 15 Sep 2010 21:17:56 +0000 |
| Subject: | note 40995 deleted from function.chr by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-172608@lists.php.net to get a copy of this message | ||
Note Submitter: mcusack at fastlanecompanies dot com
----
when working with output to a windows system i.e. a textfile the end of line "\n" will not
return a valid newline that windows will understand (this is due to a lack of standards accross OS
types) this is because windows reads new lines as carriage return and an additional char the
linefeed the traditional "\n" so in short use the following to produce a new line under a
windows text environment "\r\n"
// not tested but this should work in most cases (i think....)
<?php
function win_nl2br($stringtext) {
return str_replace("\r\n", "<br>", $stringtext);
}
function win_br2nl($stringtext) {
return str_replace("<br>", "\r\n", $stringtext);
}
?>
Hope this is as informative to you as it was to me ......