| 
	
 | 
 Posted by bobzimuta on 06/17/91 11:39 
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...
 
  
Navigation:
[Reply to this message] 
 |