Reply to how to loop thru this

Your name:

Reply:


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

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация