note 79582 added to function.count

From: Date: Tue, 04 Dec 2007 14:41:00 +0000
Subject: note 79582 added to function.count
Groups: php.notes 
Request: Send a blank email to php-notes+get-132793@lists.php.net to get a copy of this message
If, like Anonymous, you are interested in the performances of loops in PHP, please check this very useful benchmark link : http://www.php.lt/benchmark/phpbench.php Results may surprise you. For the associative array $a containing 100 elements, it seems this is the fastest way : <?php $k = array_keys($a); $v = array_values($a); $c = count($k); for ($i = 0; $i < $c; ++$i) { // do stuff with $k[$i] and $v[$i] } ?> Cheers ---- Server IP: 193.190.198.20 Probable Submitter: 193.121.99.41 ---- Manual Page -- http://www.php.net/manual/en/function.count.php Edit -- https://master.php.net/note/edit/79582 Del: integrated -- https://master.php.net/note/delete/79582/integrated Del: useless -- https://master.php.net/note/delete/79582/useless Del: bad code -- https://master.php.net/note/delete/79582/bad+code Del: spam -- https://master.php.net/note/delete/79582/spam Del: non-english -- https://master.php.net/note/delete/79582/non-english Del: in docs -- https://master.php.net/note/delete/79582/in+docs Del: other reasons-- https://master.php.net/note/delete/79582 Reject -- https://master.php.net/note/reject/79582 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#132793) next »