note 27553 deleted from function.fgets by sniper
| From: | sniper@php.net | Date: | Sat, 03 Jan 2004 02:46:36 +0000 |
| Subject: | note 27553 deleted from function.fgets by sniper | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-62832@lists.php.net to get a copy of this message | ||
Note Submitter: ben@aetherlardsanctum.net (remove lipid)
----
One solution for dealing with files generated by Macs, when you can't turn on auto detection of
line endings, is to read the file from the output pipe of the tr program. This is useful when
dealing with huge files that you would not want to just read into memory and split().
Example:
$cmd="/usr/bin/tr <$FileName '\\r' '\\n' ";
$f=popen($cmd,'r');
while($line=fgets($f,4096))
{
// blah blah blah
}
if the above command doesn't work for you, this might:
$cmd="/bin/bash -c \"cat $FileName | /usr/bin/tr '\\r' '\\n' \"
";