note 37359 added to function.count
| From: | mike at xlr8studios dot com | Date: | Wed, 12 Nov 2003 03:09:54 +0000 |
| Subject: | note 37359 added to function.count | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-60272@lists.php.net to get a copy of this message | ||
In repsonse to andreas,
Your execution time was cut so dramatically because you aren't calling count() 1500 times in
your script, so it is no longer counting 1500 elements 1500 times. Somebody else can do the math
there but lets see you count that fast.
The length of your array shouldn't be changing during a loop so their is no reason to check the
length with each iteration. By assigning it to the variable you only call count once. The magic of
variables.
You should also check out the foreach loop, as this will do the exact same thing but is geared
specifically towards working with arrays.
foreach ($array as $key => $val)
{
// do something
}
Have fun,
Mike
----
Manual Page -- http://www.php.net/manual/en/function.count.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+37359
Delete -- http://master.php.net/manage/user-notes.php?action=delete+37359&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+37359&report=yes
Search -- http://master.php.net/manage/user-notes.php