日期:2014-05-17 浏览次数:20521 次
<root> <rows> <errMsg text=""/> <retValue text="true"/> </rows> <records> <productno text="000321"/> <billno text=""/> <orderno text="D004410439"/> <out_trade_no text="100001"/> <plcprem text="0.0"/> <orderprem text="50.0"/> <commision text="0.0"/> </records> .... <root>
Array ( [rows] => Array ( [errMsg] => [retValue] => true ) [records] => Array ( [productno] =>000321 [billno] => [orderno] =>D004410439 [out_trade_no] => 100001 [plcprem] =>0.0 [orderprem] =>50.0 [commision] =>0.0 ) ..... )
$s =<<< XML <root> <rows> <errMsg text=""/> <retValue text="true"/> </rows> <records> <productno text="000321"/> <billno text=""/> <orderno text="D004410439"/> <out_trade_no text="100001"/> <plcprem text="0.0"/> <orderprem text="50.0"/> <commision text="0.0"/> </records> </root> XML; $obj = simplexml_load_string($s); $r = array(); foreach($obj as $name=>$nodes) { foreach($nodes as $k=>$v) { $t = (array)$v->attributes()->text; $r[$name][$k] = $t[0]; } } print_r($r);
------解决方案--------------------