View Single Post

  #8 (permalink)  
Old 05-08-2008
Iván Sánchez Ortega
 
Posts: n/a
Default Re: For loop question?

Ivan Marsh wrote:

>>> Isn't foreach simply creating a for loop based on the size of the array?

>>
>> No.

>
> Can you expand on that?


Sorry, I'm just not in the mood for a lesson on data structures, ordered
maps, and object iterators. It'd take a couple of hours.

However:

Stop thinking of PHP arrays as C arrays. PHP arrays are ordered maps. They
don't even have to have integer indexes.

Do read the PHP manual on arrays, the foreach() construct and object
iterators.

Grab a C/C++ book which covers the STL library, so you can see the
differences between a vector, an array, a map, a hash table, and an ordered
hash table.


Cheers,
--
----------------------------------
Iván Sánchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-

The naked truth of it is, I have no shirt.
-- William Shakespeare, "Love's Labour's Lost"

Reply With Quote