I shared the code for the first time. Today I used simplexml to parse xml files and searched for a lot of methods to directly convert object array objects into arrays. I found that many codes are not useful and many use recursion, share my code without $ xmlsimplexml_load_file (Publicsyn. xml); * The output here is the object (SimpleXMLEle
I shared the code for the first time. Today I used simplexml to parse xml files and searched for a lot of methods to directly convert object array objects into arrays. I found that many codes are not useful and many use recursion, share my code without $ xml = simplexml_load_file ('Public/syn. xml ');/* the output here is the object (SimpleXMLEle
I shared the code for the first time. Today I used simplexml to parse the xml file and searched for a lot of methods to directly convert the object array object into an array. I found that many codes are not easy to use.
Many of them use recursion to share my code. <无>
$ Xml = simplexml_load_file ('Public/syn. xml ');/* the output here is 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);/* the output here is 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 "}}}*/