note 74758 modified in function.count by danbrown
| From: | danbrown@php.net | Date: | Fri, 09 Jan 2009 22:59:57 +0000 |
| Subject: | note 74758 modified in function.count by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-149010@lists.php.net to get a copy of this message | ||
NEVER USE IN CYCLES!
<?php
//size of $arr ~ 2000 elements
//wrong variant (Time exec ~ 19 sec)
for($i=0;$i<count($arr);$i++)
{
//...
}
//right variant(Time exec ~ 0.2 sec)
$arr_size=count($arr);
for($i=0;$i<$arr_size;$i++)
{
//...
}
?>
it was discovered experimentally.
--was--
NEVER USE IN CYCLES!
//size of $arr ~ 2000 elements
//wrong variant (Time exec ~ 19 sec)
for($i=0;$i<count($arr);$i++)
{
...
}
//right variant(Time exec ~ 0.2 sec)
$arr_size=count($arr);
for($i=0;$i<$arr_size;$i++)
{
...
}
it was discovered experimentally.
http://php.net/manual/en/function.count.php