<? header("Content-Type: text/html; charset=gb2312"); $t=new xml2array(); $t->str="http://***.com/qiminphp.xml"; $m=$t->xarray(); class xml2array{ public $str = ''; public $type = 1; //0为字符串,1为文件 function readxml(){ if($this->type==1){ $this->xmlstr = simplexml_load_file($this->str); }else{ $this->xmlstr = simplexml_load_string($this->str); } } function xarray(){ $this->readxml(); $arrstr = array(); $str = serialize($this->xmlstr); $str = str_replace('O:16:"SimpleXMLElement"', 'a', $str); $arrstr = unserialize($str); return $arrstr; }}?>

评论