You are here: Re: Return value of 'each', 'current', 'next', 'end' « PHP Programming Language « IT news, forums, messages
Re: Return value of 'each', 'current', 'next', 'end'

Posted by Daz on 10/16/06 18:00

Chung Leong wrote:
> 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.

Completely correct of course. I have no idea why I didn't think of that
one. I tend to go out of my way whenever possible to create
non-assiciative arrays when I can, for the reason I illistrated.
Perhaps it's a bad habit, but it has served me well in the past under
certain circumstances. I think this is why associative arrays
completely slipped my mind.

Thanks for clearing that up, and my humble apologies for any confusion
caused to the OP.

All the best.

Daz.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация