note 71252 added to function.feof
| From: | cmratforestfactorydotde at osu1 dot php dot net | Date: | Sun, 19 Nov 2006 16:57:32 +0000 |
| Subject: | note 71252 added to function.feof | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-119871@lists.php.net to get a copy of this message | ||
Here's solution 3:
<?
$fp = fopen("myfile.txt", "r");
while ( ($current_line = fgets($fp)) !== false ) {
// do stuff to the current line here
}
fclose($fp);
?>
AFAICS fgets() never returns an empty string, so we can also write:
<?
$fp = fopen("myfile.txt", "r");
while ( $current_line = fgets($fp) ) {
// do stuff to the current line here
}
fclose($fp);
?>
----
Server IP: 217.13.201.10
Probable Submitter: 82.135.67.158
----
Manual Page -- http://www.php.net/manual/en/function.feof.php
Edit -- https://master.php.net/note/edit/71252
Del: integrated -- https://master.php.net/note/delete/71252/integrated
Del: useless -- https://master.php.net/note/delete/71252/useless
Del: bad code -- https://master.php.net/note/delete/71252/bad+code
Del: spam -- https://master.php.net/note/delete/71252/spam
Del: non-english -- https://master.php.net/note/delete/71252/non-english
Del: in docs -- https://master.php.net/note/delete/71252/in+docs
Del: other reasons-- https://master.php.net/note/delete/71252
Reject -- https://master.php.net/note/reject/71252
Search -- https://master.php.net/manage/user-notes.php