|
Posted by whiskey on 10/31/06 09:07
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 ;-)
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;
> --
> PleegWat
> Remove caps to reply
Navigation:
[Reply to this message]
|