PHP自定义函数xmlToArray实例

将xml转为array

function xmlToArray($xml) {

//将XML转为array

$array_data = json_decode(json_encode(simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA)), true);

return $array_data;

}

效果:
 



wxd930ea5d5a258f4f

10000100

1000

test

ibuaiVcKdpRxkhJA

9A0A8659F005D6984697E2CA0A9CF3B7

转化成:

Array

(

[appid] => wxd930ea5d5a258f4f

[mch_id] => 10000100

[device_info] => 1000

[body] => test

[nonce_str] => ibuaiVcKdpRxkhJA

[sign] => 9A0A8659F005D6984697E2CA0A9CF3B7

)



 

你可能感兴趣的:(PHP自定义函数xmlToArray实例)