Anyone who knows alot about W3's Document Object Model - look at this thread:
I'm working on an own DOM extension to PHP. Using PHP classes.
Now I have encounterd a problem with the "NodeList" interface (read class).
Every DOM - Object that inherit from the "Node" && can contain children has a property called "childNodes".
This property is a member of the "NodeList" interface. (read an member of the class NodeList, therefor an object)
So for ex. if I want to reach the second child of the current object I use the following syntax:
$currentobj->childNodes->item(2)
Now to my problem:
The W3 specification aslo say thet you can reach a child with brackets like an array:
$currentobject->childNodes[2]
My question is how to do that in PHP?
In Ecmascript (javascript) this is very easy because array's ARE objects. (in PHP that would mean the the arrays would be a class)
How do you make an object work like an array an the other way around?
Is there a way to do this?
So that you can create an object like this:
$myobj = new someclass();
and then give it array info like this:
$myobj[0] = "somestring";
echo $myobj still says "object".
Is this possible?
Thans for any replys.