| Newsgroups |
php.notes |
| Message-ID |
<[email protected]> |
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...
----
Server IP: 69.147.83.197
Probable Submitter: 81.76.49.11
----
Manual Page -- http://www.php.net/manual/en/function.count.php
Edit -- https://master.php.net/note/edit/86296
Del: integrated -- https://master.php.net/note/delete/86296/integrated
Del: useless -- https://master.php.net/note/delete/86296/useless
Del: bad code -- https://master.php.net/note/delete/86296/bad+code
Del: spam -- https://master.php.net/note/delete/86296/spam
Del: non-english -- https://master.php.net/note/delete/86296/non-english
Del: in docs -- https://master.php.net/note/delete/86296/in+docs
Del: other reasons-- https://master.php.net/note/delete/86296
Reject -- https://master.php.net/note/reject/86296
Search -- https://master.php.net/manage/user-notes.php