You are here: Re: When is an array not an array? « PHP Programming Language « IT news, forums, messages
Re: When is an array not an array?

Posted by PleegWat on 10/31/06 09:40

In article <1162285622.826148.302460@m73g2000cwd.googlegroups.com>,
whiskey says...
> On Oct 31, 12:27 am, PleegWat
> <pleeg...@PLEEGWAT.leegwater-68.demon.nl.INVALID> wrote:
> > In article <q13ck2d3tc2204gdsi3db9q0bds510p...@4ax.com>, Andy Hassall
> > says...
> >
> > > Failing that, it'd be somewhat useful if DOMNodeList had a method to
> > > convert itself into an actual array, but it doesn't seem to have that
> > > either.
> > If, as whiskey says, the nodes are properties of the object, you can do
> > an explicit cast of the object to an array:
> >
> > $arrayofnodes = (array)$nodelist;
>
> I dare say you can not cast a DOMNodeList to an array. Because, when
> converting an object to an array, you get the properties of the object.
> And DOMNodeList has only one porperty, which is "length" (and useless
> in this context).
>
> Anyway, I can't find any reason why one will ever need to convert a
> DOMNodeList to an array since it provides a method to retrieve a node
> specified by it's index ("item()"). Moreover, PHP5 offers the ability
> to iterate through objects. So why this fuss ?
>
> PleegWat, I never said nodes are properties. All I said was that PHP5
> adds the ability to iterate the visible properties of an object. But
> that's the default. You can customize the way PHP iterates through
> objects by implementing the "Iterator" or "IteratorAggregate"
> interfaces ;-)

(top-posting fixed)

Sorry, misunderstood you then. I did take a quick look at the manual but
I couldn't find anything about hte DOMNodeList class.

--
PleegWat
Remove caps to reply

 

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

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