note 81798 added to function.sizeof
| From: | svanegmond at tinyplanet dot ca | Date: | Thu, 13 Mar 2008 19:12:22 +0000 |
| Subject: | note 81798 added to function.sizeof | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-137033@lists.php.net to get a copy of this message | ||
For people who use this kind of idiom:
for ($i=0; $i<sizeof($array); $i++) {
...
}
At least in PHP4, you will notice a large performance improvement if you switch to:
$max = sizeof($array);
for ($i=0; $i<$max; $i++) {
...
}
I had an array with a few thousand items in it, each of them a map with 5 key-value pairs, and just
for'ing through the array took a second of CPU on a decent machine.
----
Server IP: 216.235.15.211
Probable Submitter: 206.223.175.72
----
Manual Page -- http://www.php.net/manual/en/function.sizeof.php
Edit -- https://master.php.net/note/edit/81798
Del: integrated -- https://master.php.net/note/delete/81798/integrated
Del: useless -- https://master.php.net/note/delete/81798/useless
Del: bad code -- https://master.php.net/note/delete/81798/bad+code
Del: spam -- https://master.php.net/note/delete/81798/spam
Del: non-english -- https://master.php.net/note/delete/81798/non-english
Del: in docs -- https://master.php.net/note/delete/81798/in+docs
Del: other reasons-- https://master.php.net/note/delete/81798
Reject -- https://master.php.net/note/reject/81798
Search -- https://master.php.net/manage/user-notes.php