note 27553 added to function.fgets
| From: | (remove lipid) | Date: | Tue, 10 Dec 2002 21:58:46 +0000 |
| Subject: | note 27553 added to function.fgets | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-40674@lists.php.net to get a copy of this message | ||
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' \"
";
--
http://www.php.net/manual/en/function.fgets.php
http://master.php.net/manage/user-notes.php?action=edit+27553
http://master.php.net/manage/user-notes.php?action=delete+27553
http://master.php.net/manage/user-notes.php?action=reject+27553