$xml =simplexml_load_file('Public/syn.xml'); /* 此处打印出来的结果是 object(SimpleXMLElement)#20 (1) { ["server"]=> array(2) { [0]=> object(SimpleXMLElement)#26 (2) { ["server_name"]=> array(2) { [0]=> string(3) "777" [1]=> string(6) "123456" } ["server_ip"]=> string(13) "xxx.xxx.xxx.xxx" } [1]=> object(SimpleXMLElement)#27 (2) { ["server_name"]=> array(2) { [0]=> string(3) "888" [1]=> string(6) "123456" } ["server_ip"]=> string(13) "xxx.xxx.xxx.xxx" } } } */ $json_xml=json_encode($xml); $dejson_xml=json_decode($json_xml,true); /* 此处打印出来的结果是 array(1) { ["server"]=> array(2) { [0]=> array(2) { ["server_name"]=> array(2) { [0]=> string(3) "777" [1]=> string(6) "123456" } ["server_ip"]=> string(13) "xxx.xxx.xxx.xxx" } [1]=> array(2) { ["server_name"]=> array(2) { [0]=> string(3) "888" [1]=> string(6) "123456" } ["server_ip"]=> string(13) "xxx.xxx.xxx.xxx" } } } */