$xml_php = "<xml>
<appid>wx123ASb1c23370ec43b</appid>
<customs>ZHONGWEN_AA</customs>
<mch_customs_no>D54841</mch_customs_no>
<mch_id>1548254101</mch_id>
<order_fee>12310</order_fee>
<out_trade_no>12112394212604</out_trade_no>
<product_fee>13110</product_fee>
<sign>2FF6CEF879FB9123CD580222E671E9D4</sign>
<transaction_id>500623231201511241751403478</transaction_id>
<transport_fee>0</transport_fee>
<fee_type>CNY</fee_type>
<sub_order_no>13612496832676251</sub_order_no>
</xml>";
转换函数:
function xmlToArray($str) {
// 将XML转为array
$array_data = json_decode(json_encode(simplexml_load_string($str, 'SimpleXMLElement', LIBXML_NOCDATA)), true);
return $array_data;
}
转换后:
print_r(xmlToArray($str));