if ($Atmp1=explode('>',$s,2) xml2array_sub($A,$Atmp1[1]); } return $A; } function xml2array_sub(&$A,$s) { global $error_msg; for ($c=0;ereg('<([^<>/ ]*)( [^<>]*)?/>(.*)',$s,$Atmp1) or ereg('<([^<>/ ]*)( [^<>]*)?>(.*)',$s,$Atmp1) and $Atmp2=explode('',$Atmp1[3],2);++$c) { $E=array(); $tag=$Atmp1[1]; if ($Atmp1[2]) { $Atmp3=explode(' ',substr($Atmp1[2],1)); foreach ($Atmp3 as $d) { $Atmp4=explode('=',$d,2); $Atmp4[1]=ereg_replace('^"(.*)"$','\1',$Atmp4[1]); $E[$Atmp4[0]]=$Atmp4[1]; } } if ($Atmp2) { if (!xml2array_sub($E,$Atmp2[0])) { $E=$Atmp2[0]; } $s=$Atmp2[1]; $Atmp2=false; } else { $s=$Atmp1[3]; } if ($A[$tag]) { if (!is_array($A[$tag]) or !$A[$tag][0]) { $Atag=$A[$tag]; unset($A[$tag]); $A[$tag][]=$Atag; } if ($E) { $A[$tag][]=$E; } } else { if ($E) { $A[$tag]=$E; if ($tag=='$ErrorMsg') $error_msg=$E; } } } return $c;