|
Posted by Nancy on 10/16/31 11:39
Thanks bob, this gave me the direction I needed to struggle through.
nan
"bobzimuta" <ejmalone@gmail.com> wrote in message
news:1139382691.349070.169960@g47g2000cwa.googlegroups.com...
>i was going to suggest a recursive way to build an array that is
> heriarchically correct, such as
>
> array( 'DATABPP' => array( 'COUNT' => 6692, 'PRICE' => 0, ... )
>
> but i'm guessing you want something more like
> $array( 'COUNT' => 6692, 'PRICE' => 0, .... );
>
> note that it's necessary to take account for multiple tags w/ same
> name, unless all the tags are unique. If you have two tags named
> 'price', you don't want to overwrite the first value with the second.
> But I'll leave that for you :)
>
> Please note this is pseudo (not tested) and I"m doing it before bed, so
> buyer beware.
>
> function build_xml( $node_array )
> {
> global $results;
> if( !$node_array[ 'children'] )
> {
> $results[ $node_array['name'] ] = $node_array[ 'tagData' ];
> }
> else
> {
> foreach( $node_array['children'] as $child )
> {
> build_xml( $child );
> }
> }
> }
>
> $results = array();
> build_xml( $some_root_array );
>
> Yes, it could be done by passing a reference to the function...
>
[Back to original message]
|