note 108685 added to function.fgets
| From: | apardo at NOSPAM dot gmail dot com | Date: | Thu, 17 May 2012 16:03:37 +0000 |
| Subject: | note 108685 added to function.fgets | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-188037@lists.php.net to get a copy of this message | ||
This is a a simple function to detect end of line type for any file.
<?php
function detectEndOfLine($file)
{
$handle = @fopen($file, "r");
if ($handle)
{
$char=0;
while (!$eol || feof($handle))
{
$char++;
$line = fgets($handle, $char);
$eol = preg_match("/(\r)+/", $line)? "W" : "";
if(!$eol) $eol = preg_match("/(\n)+/", $line)? "L" : "";
}
return $eol;
fclose($handle);
}
}
?>
----
Server IP: 69.147.83.197
Probable Submitter: 186.109.90.172
----
Manual Page -- http://www.php.net/manual/en/function.fgets.php
Edit -- https://master.php.net/note/edit/108685
Del: integrated -- https://master.php.net/note/delete/108685/integrated
Del: useless -- https://master.php.net/note/delete/108685/useless
Del: bad code -- https://master.php.net/note/delete/108685/bad+code
Del: spam -- https://master.php.net/note/delete/108685/spam
Del: non-english -- https://master.php.net/note/delete/108685/non-english
Del: in docs -- https://master.php.net/note/delete/108685/in+docs
Del: other reasons-- https://master.php.net/note/delete/108685
Reject -- https://master.php.net/note/reject/108685
Search -- https://master.php.net/manage/user-notes.php