note 108281 deleted from function.count by googleguy
| From: | googleguy@php.net | Date: | Mon, 17 Sep 2012 00:06:53 +0000 |
| Subject: | note 108281 deleted from function.count by googleguy | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-190818@lists.php.net to get a copy of this message | ||
Note Submitter: carlos56_dal at hotmail dot com
----
When use an huge array, it's recommended to set a variable with the size of the array, p.g.
<?php
$array_size = count($your_array);
for($i = 0; $i < $array_size; $i++)
{
// Process array data
}
?>
It's quicker than:
<?php
for($i = 0; $i < sizeof($your_array); $i++)
{
// Process array data
}
?>
In the first example, run the sizeof function once, however in the second example run n times the
sizeof function