xml代碼
$xml = "<xml>
<appid>wx2421b1c4370ec43b</appid>
<customs>ZHENGZHOU_BS</customs>
<mch_customs_no>D00411</mch_customs_no>
<mch_id>1262544101</mch_id>
<order_fee>13110</order_fee>
<out_trade_no>15112496832609</out_trade_no>
<product_fee>13110</product_fee>
<sign>8FF6CEF879FB9555CD580222E671E9D4</sign>
<transaction_id>1006930610201511241751403478</transaction_id>
<transport_fee>0</transport_fee>
<fee_type>CNY</fee_type>
<sub_order_no>15112496832609001</sub_order_no>
</xml>";
function xmlToArray2($xml) {
// 將XML轉爲array
$array_data = json_decode(json_encode(simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA)), true);
return $array_data;
}
xml轉換成數組後:
print_r(xmlToArray2($xml));
更多php技術交流,可加Q羣:884743303,裏面各路大神爲您保駕護航!