|  | Posted by sam on 12/29/05 13:05 
Hi,
 I want to treverse the following structure in PHP:
 
 Array
 (
 [0] => stdClass Object
 (
 [xml] => Array
 (
 [0] => stdClass Object
 (
 [fileName] => Array
 (
 [0] => stdClass Object
 (
 [name] => Array
 (
 [0] => "bbbbbb"
 )
 
 [type] => Array
 (
 [0] => "New"
 )
 
 )
 
 )
 .....
 
 But I don't know how to get to the next "Array" from
 the "stdClass Object".
 
 Here the functions used in my program, but it does not work as I expected:
 
 //save file to xml format
 function save_as_model_list_xml($model_list_file)
 {
 $arr = $this->pointer;
 if ($arr) {
 $fh = fopen($model_list_file, 'w') or die("can't open file");
 fwrite($fh, "<modelList>\n");
 
 $modelName = "";
 $modelList_Array = $arr[modelList][0][model];
 foreach( $modelList_Array as $model => $model_elem ) {
 $modelName = $model_elem[0][modelName];
 $fileName = $model_elem[0][fileName];
 $xml = '\t<model modelName="'.$modelName.'" fileName="'.$fileName.'"
 />\n';
 fwrite($fh, $xml);
 }
 // write a new model name and its filename
 $xml = '<model modelName="'.$modelName.'"
 fileName="'.$model_list_file.'" />\n';
 fwrite($fh, $xml);
 
 fwrite($fh, "</modelList>\n");
 fclose($fh);
 }
 }
 
 $this->pointer is pointing to starting Array.
 
 
 Thanks
 Sam
  Navigation: [Reply to this message] |