note 43635 added to function.array-keys

From: Date: Mon, 28 Jun 2004 19:51:23 +0000
Subject: note 43635 added to function.array-keys
Groups: php.notes 
Request: Send a blank email to php-notes+get-72070@lists.php.net to get a copy of this message
I can't take it...code like this: //Assign $array up here for($j = 0; $j < count($array); $j++) { //Do stuff } Is horribly broken. Don't do that...bad monkey. count($array) is generally loop invariant. Do $len = count($array); for($j = 0; $j < $len; $j++) { //Do stuff } If count($array) is not loop inviant then change it by the same amount that $array is changed ---- Manual Page -- http://www.php.net/manual/en/function.array-keys.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+43635 Delete -- http://master.php.net/manage/user-notes.php?action=delete+43635&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+43635&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#72070) next »