| Posted by Chung Leong on 10/15/06 04:44 
Daz wrote:> $array[(sizeof($array)-1)] ="new value";
 > should also work.
 >
 > I would imagine that end() and sizeof() work very much the same way.
 > They probably both iterate through the array to the end only 1 counts
 > as it goes, and the other returns the key of the last element in the
 > array.
 
 No. end() move the internal point inside the array to the last element.
 sizeof() returns the number of elements inside the array. As Pedro
 illustrated, the distinction is most obvious when you have an
 associative array.
 
 Arrays in PHP are hybrid linked-lists and hash tables. Each elements
 links to its neighbors and can simultanously be quickly accessed
 through a hash key.
 [Back to original message] |