note 86296 deleted from function.count by danbrown

From: Date: Fri, 09 Jan 2009 22:58:13 +0000
Subject: note 86296 deleted from function.count by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-149003@lists.php.net to get a copy of this message
Note Submitter: Anonymous ---- redbehelit at yahoo dot com wrote: ----------------------------------------------- for ($i = 0; $i < count($arr); i++) { This loop is going to try to traverse to $arr[26] which does not exist. The last element is at index number 25. We can fix this with a minor edit: for ($i = 0; $i < count($arr)-1; i++) { ------------------------------------------------ That is incorrect. Even if count IS 26 it won't traverse it because you arre using the < operator. Think about it : 26 is NOT less than 26...

« previous php.notes (#149003) next »