note 47588 added to function.fgets
| From: | gnif at spacevs dot com | Date: | Mon, 22 Nov 2004 05:57:47 +0000 |
| Subject: | note 47588 added to function.fgets | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-80849@lists.php.net to get a copy of this message | ||
Reading the entire file in using fgetc is slow, here is a faster (and less bulky) alternative:
<?PHP
$delim = '|'
$text = file_get_contents('myfile.txt');
$items = explode($delim, $text);
?>
$content is now an array of each entry in the file, just itterate it, eg:
<?PHP
for ($i=0; $i<count($items); $i++) echo $items[$i];
?>
--
http://www.spacevs.com
----
Manual Page -- http://www.php.net/manual/en/function.fgets.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+47588
Delete -- http://master.php.net/manage/user-notes.php?action=delete+47588&report=yes
Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+47588&report=yes&reason=bad+code
Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+47588&report=yes&reason=spam
Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+47588&report=yes&reason=useless+example
Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+47588&report=yes&reason=contains+commercial+links
Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+47588&report=yes&reason=useless+note
Reject -- http://master.php.net/manage/user-notes.php?action=reject+47588&report=yes
Search -- http://master.php.net/manage/user-notes.php