note 13757 deleted from features.file-upload by irc-html
| From: | irc-html@php.net | Date: | Sat, 19 Jan 2002 20:34:00 +0000 |
| Subject: | note 13757 deleted from features.file-upload by irc-html | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-25357@lists.php.net to get a copy of this message | ||
For dealing with Mac and DOS/Windows files on *nix you'll want to replace all instances of a CR
and CRLF with LF. Here's a function to do just that:
/**
* name: replace_returns
* author: nhyde@NOSPAM.bigDrift.com
* description: replace DOS/Windows and Mac line endings with Unix-style LineFeeds
* param: filedata - string - data from the file
* returns: string with requested line endings
**/
function replace_returns ($filedata) {
if ( ereg(chr(13), $filedata) ) {
$temp_data = $filedata;
// replace CRLF combos for DOS/Windows files
$temp_data = ereg_replace(chr(13).chr(10), chr(10), $temp_data);
// replace the leftover CRs for Mac files
$temp_data = ereg_replace(chr(13), chr(10), $temp_data);
return $temp_data;
}
else {
return $filedata;
}
}