note 108281 added to function.count

From: Date: Fri, 13 Apr 2012 19:40:52 +0000
Subject: note 108281 added to function.count
Groups: php.notes 
Request: Send a blank email to php-notes+get-187113@lists.php.net to get a copy of this message
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 ---- Server IP: 69.147.83.197 Probable Submitter: 201.141.116.134 ---- Manual Page -- http://www.php.net/manual/en/function.count.php Edit -- https://master.php.net/note/edit/108281 Del: integrated -- https://master.php.net/note/delete/108281/integrated Del: useless -- https://master.php.net/note/delete/108281/useless Del: bad code -- https://master.php.net/note/delete/108281/bad+code Del: spam -- https://master.php.net/note/delete/108281/spam Del: non-english -- https://master.php.net/note/delete/108281/non-english Del: in docs -- https://master.php.net/note/delete/108281/in+docs Del: other reasons-- https://master.php.net/note/delete/108281 Reject -- https://master.php.net/note/reject/108281 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#187113) next »