note 37318 added to function.count
| From: | andreas at sassermann dot de | Date: | Mon, 10 Nov 2003 14:33:45 +0000 |
| Subject: | note 37318 added to function.count | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-60210@lists.php.net to get a copy of this message | ||
One note about speed:
I just had an impressing speedup with a very tiny change.
Having an array with 1500 Elements, the following code took about 15 seconds:
<?php
for($intItem = 0; $intItem < count($aItemData); $intItem++)
{
// ... do something ...
}
?>
By just assigning the number of items to a variable and comparing against this, reduced the total
execution time to 0.9 seconds (yes TO, not BY)
<?php
$intCount = count($aItemData);
for($intItem = 0; $intItem < $intCount; $intItem++)
{
// ... do still the same ...
}
?>
----
Manual Page -- http://www.php.net/manual/en/function.count.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+37318
Delete -- http://master.php.net/manage/user-notes.php?action=delete+37318&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+37318&report=yes
Search -- http://master.php.net/manage/user-notes.php