note 93188 added to function.fgetcsv
| From: | k at vi1 dot co dot uk | Date: | Thu, 27 Aug 2009 19:07:26 +0000 |
| Subject: | note 93188 added to function.fgetcsv | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-159942@lists.php.net to get a copy of this message | ||
A quick note regarding parsing long files, and using loops.
DO NOT place the count function inside the loop arguments as it is re calculated at every occurance,
so for instance
// $array = array with 20,000 vals
while ($i < count($array))
count() will get executed 20,000 times.
To fix this just simply assign the value of count to a variable e.g.
$total = count($array);
while ($i<count($array))
This time there will be no overheads!
----
Server IP: 87.124.86.41
Probable Submitter: 90.216.49.83 (proxied: 90.216.49.83)
----
Manual Page -- http://www.php.net/manual/en/function.fgetcsv.php
Edit -- https://master.php.net/note/edit/93188
Del: integrated -- https://master.php.net/note/delete/93188/integrated
Del: useless -- https://master.php.net/note/delete/93188/useless
Del: bad code -- https://master.php.net/note/delete/93188/bad+code
Del: spam -- https://master.php.net/note/delete/93188/spam
Del: non-english -- https://master.php.net/note/delete/93188/non-english
Del: in docs -- https://master.php.net/note/delete/93188/in+docs
Del: other reasons-- https://master.php.net/note/delete/93188
Reject -- https://master.php.net/note/reject/93188
Search -- https://master.php.net/manage/user-notes.php