php - How to convert this tree data structure into an array -
i used tree data structure. https://github.com/nicmart/tree
and created tree object following xml code both shown below:
<xgameapp version="1.0"> <states> <state id="1" color="red"></state> <state id="2" color="blue"> hello state </state> </states> <actions> <transitions> <transition from="1" to="2"> demo transition </transition> <transition from="2" to="1"></transition> </transitions> <orientations> <x1> <y1> <cw> <orientation fronangle="120" toangle="45"></orientation> <orientation fronangle="270" toangle="120"></orientation> </cw> <ccw> <orientation fronangle="45" toangle="120"></orientation> <orientation fronangle="120" toangle="270"></orientation> </ccw> </y1> </x1> </orientations> </actions> </xgameapp> tree\builder\nodebuilder object ( [nodestack:tree\builder\nodebuilder:private] => array ( [0] => tree\node\node object ( [value:tree\node\node:private] => array ( [name] => xgameapp [attributes] => array ( [version] => 1.0 ) ) [parent:tree\node\node:private] => [children:tree\node\node:private] => array ( [0] => tree\node\node object ( [value:tree\node\node:private] => array ( [name] => states ) [parent:tree\node\node:private] => tree\node\node object *recursion* [children:tree\node\node:private] => array ( [0] => tree\node\node object ( [value:tree\node\node:private] => array ( [name] => state [attributes] => array ( [id] => 1 [color] => red ) ) [parent:tree\node\node:private] => tree\node\node object *recursion* [children:tree\node\node:private] => array ( ) ) [1] => tree\node\node object ( [value:tree\node\node:private] => array ( [name] => state [attributes] => array ( [id] => 2 [color] => blue ) [value] => hello state ) [parent:tree\node\node:private] => tree\node\node object *recursion* [children:tree\node\node:private] => array ( ) ) ) ) [1] => tree\node\node object ( [value:tree\node\node:private] => array ( [name] => actions ) [parent:tree\node\node:private] => tree\node\node object *recursion* [children:tree\node\node:private] => array ( [0] => tree\node\node object ( [value:tree\node\node:private] => array ( [name] => transitions ) [parent:tree\node\node:private] => tree\node\node object *recursion* [children:tree\node\node:private] => array ( [0] => tree\node\node object ( [value:tree\node\node:private] => array ( [name] => transition [attributes] => array ( [from] => 1 [to] => 2 ) [value] => demo transition ) [parent:tree\node\node:private] => tree\node\node object *recursion* [children:tree\node\node:private] => array ( ) ) [1] => tree\node\node object ( [value:tree\node\node:private] => array ( [name] => transition [attributes] => array ( [from] => 2 [to] => 1 ) ) [parent:tree\node\node:private] => tree\node\node object *recursion* [children:tree\node\node:private] => array ( ) ) ) ) [1] => tree\node\node object ( [value:tree\node\node:private] => array ( [name] => orientations ) [parent:tree\node\node:private] => tree\node\node object *recursion* [children:tree\node\node:private] => array ( [0] => tree\node\node object ( [value:tree\node\node:private] => array ( [name] => x1 ) [parent:tree\node\node:private] => tree\node\node object *recursion* [children:tree\node\node:private] => array ( [0] => tree\node\node object ( [value:tree\node\node:private] => array ( [name] => y1 ) [parent:tree\node\node:private] => tree\node\node object *recursion* [children:tree\node\node:private] => array ( [0] => tree\node\node object ( [value:tree\node\node:private] => array ( [name] => cw ) [parent:tree\node\node:private] => tree\node\node object *recursion* [children:tree\node\node:private] => array ( [0] => tree\node\node object ( [value:tree\node\node:private] => array ( [name] => orientation [attributes] => array ( [fronangle] => 120 [toangle] => 45 ) ) [parent:tree\node\node:private] => tree\node\node object *recursion* [children:tree\node\node:private] => array ( ) ) [1] => tree\node\node object ( [value:tree\node\node:private] => array ( [name] => orientation [attributes] => array ( [fronangle] => 270 [toangle] => 120 ) ) [parent:tree\node\node:private] => tree\node\node object *recursion* [children:tree\node\node:private] => array ( ) ) ) ) [1] => tree\node\node object ( [value:tree\node\node:private] => array ( [name] => ccw ) [parent:tree\node\node:private] => tree\node\node object *recursion* [children:tree\node\node:private] => array ( [0] => tree\node\node object ( [value:tree\node\node:private] => array ( [name] => orientation [attributes] => array ( [fronangle] => 45 [toangle] => 120 ) ) [parent:tree\node\node:private] => tree\node\node object *recursion* [children:tree\node\node:private] => array ( ) ) [1] => tree\node\node object ( [value:tree\node\node:private] => array ( [name] => orientation [attributes] => array ( [fronangle] => 120 [toangle] => 270 ) ) [parent:tree\node\node:private] => tree\node\node object *recursion* [children:tree\node\node:private] => array ( ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) )
now i'm trying represent output nested array or way friendly human eye.
thanks.
Comments
Post a Comment