note 114924 added to function.count

From: Date: Mon, 28 Apr 2014 02:14:34 +0000
Subject: note 114924 added to function.count
Groups: php.notes 
Request: Send a blank email to php-notes+get-199341@lists.php.net to get a copy of this message
If you want to run through large arrays don't use count() function in the loops , its a over head in performance, copy the count() value into a variable and use that value in loops for a better performance. Eg: // Bad approach for($i=0;$i<count($some_arr);$i++) { // calculations } // Good approach $arr_length = count($some_arr); for($i=0;$i<$arr_length;$i++) { // calculations } ---- Server IP: 103.21.58.61 Probable Submitter: 49.207.253.57 ---- Manual Page -- http://php.net/manual/en/function.count.php Edit -- https://master.php.net/note/edit/114924 Del: integrated -- https://master.php.net/note/delete/114924/integrated Del: useless -- https://master.php.net/note/delete/114924/useless Del: bad code -- https://master.php.net/note/delete/114924/bad+code Del: spam -- https://master.php.net/note/delete/114924/spam Del: non-english -- https://master.php.net/note/delete/114924/non-english Del: in docs -- https://master.php.net/note/delete/114924/in+docs Del: other reasons-- https://master.php.net/note/delete/114924 Reject -- https://master.php.net/note/reject/114924 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#199341) next »