List Info

Thread: note 61703 added to control-structures.foreach




note 61703 added to control-structures.foreach
user name
2006-02-10 01:04:46
I just noticed something.  I created an array, Looped
through a mysql result with a while and added values to that
array with an index that I incremented manually, starting at
position 1.  After closing the while loop I added an element
at position 0 of the array.  When I looped through that
array with a foreach loop it evaluated the elements starting
from the first element that was added instead of starting at
position 0.  I'm not sure if that was intentional but it
does not seem to be in the documentation.  So in this case
looping through the array with a foreach was not the same as
looping through it with a for loop like this:

for($i =0; $i<count($myarray); $i++)

To anyone coming from a C or C++ background this might be
confusing.
----
Server IP: 64.71.164.2
Probable Submitter: 69.230.47.58
----
Manual Page -- http://www.php.net/manual/en/control-structures.forea
ch.php
Edit        -- http://master.php.net/manage/user-notes.php?action=
edit+61703
Delete: added to the manual -- htt
p://master.php.net/manage/user-notes.php?action=delete+61703
&report=yes&reason=added+to+the+manual
Delete: bad code            -- http://master.
php.net/manage/user-notes.php?action=delete+61703&report
=yes&reason=bad+code
Delete: spam                -- http://master.php.
net/manage/user-notes.php?action=delete+61703&report=yes
&reason=spam
Delete: useless             -- http://master.p
hp.net/manage/user-notes.php?action=delete+61703&report=
yes&reason=useless
Delete: non-english         -- http://mast
er.php.net/manage/user-notes.php?action=delete+61703&rep
ort=yes&reason=non-english
Delete: already in docs     -- http://
master.php.net/manage/user-notes.php?action=delete+61703&
;report=yes&reason=already+in+docs
Delete: other reasons       -- http://master.php.net/manage/user-
notes.php?action=delete+61703&report=yes
Reject      -- http://master.php.net/manage/user-
notes.php?action=reject+61703&report=yes
Search      -- http://ma
ster.php.net/manage/user-notes.php

-- 
PHP Notes Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub
.php

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )