note 78730 added to function.fgets
| From: | david_sitller at blackbit dot de | Date: | Thu, 25 Oct 2007 00:32:24 +0000 |
| Subject: | note 78730 added to function.fgets | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-131713@lists.php.net to get a copy of this message | ||
If you use the example from the command-description, i recommend to trim the $buffer for further
use. The line feed ist still at the end of the line. I saw this when using PHP CLI.
Like this, checking a file-list for existing entries:
$handle = fopen ("/tmp/files.txt", "r");
while (!feof($handle)) {
$buffer = fgets($handle, 4096);
if (file_exists(rtrim($filename,"\n"))) {
echo $buffer;
} else {
echo $buffer." has been removed."
}
fclose ($handle);
----
Server IP: 217.13.201.10
Probable Submitter: 80.128.54.73
----
Manual Page -- http://www.php.net/manual/en/function.fgets.php
Edit -- https://master.php.net/note/edit/78730
Del: integrated -- https://master.php.net/note/delete/78730/integrated
Del: useless -- https://master.php.net/note/delete/78730/useless
Del: bad code -- https://master.php.net/note/delete/78730/bad+code
Del: spam -- https://master.php.net/note/delete/78730/spam
Del: non-english -- https://master.php.net/note/delete/78730/non-english
Del: in docs -- https://master.php.net/note/delete/78730/in+docs
Del: other reasons-- https://master.php.net/note/delete/78730
Reject -- https://master.php.net/note/reject/78730
Search -- https://master.php.net/manage/user-notes.php