How can I traverse XML files? how can I traverse xml files and put them into the database?
Fruit
Tree
Flower
Others
Lu
Sea
Others
I want to traverse the frontend results in this way.
Reply to discussion (solution)
Organize your own display.
$ S = <
Fruit
Tree
Flower
Others
Lu
Sea
Others
EOF; $ x = simplexml_load_string ($ s); $ data = []; foreach ($ x-> Evaluations as $ Evaluations) {foreach ($ Evaluations-> Evaluation as $ Evaluation) {$ tmpData = current ($ Evaluation-> attributes ()-> data); if (! Isset ($ data ["$ tmpData"]) {$ data ["$ tmpData"] = [];} foreach ($ Evaluation-> OBJECT as $ OBJECT) {$ data ["$ tmpData"] ["$ OBJECT"] = current ($ OBJECT-> attributes ()-> data) ;}} print_r ($ data ); /* Array ([plant system] => Array ([fruit] => apple, pear [tree] => bamboo, rich bamboo [Flower] => Chrysanthemum, carnation [others] =>) [animal system] => Array ([land] => Tiger, Lion [Sea] => fish, Seahorse [others] => ))*/
Organize your own display.
$ S = <
Fruit
Tree
Flower
Others
Lu
Sea
Others
EOF; $ x = simplexml_load_string ($ s); $ data = []; foreach ($ x-> Evaluations as $ Evaluations) {foreach ($ Evaluations-> Evaluation as $ Evaluation) {$ tmpData = current ($ Evaluation-> attributes ()-> data); if (! Isset ($ data ["$ tmpData"]) {$ data ["$ tmpData"] = [];} foreach ($ Evaluation-> OBJECT as $ OBJECT) {$ data ["$ tmpData"] ["$ OBJECT"] = current ($ OBJECT-> attributes ()-> data) ;}} print_r ($ data ); /* Array ([plant system] => Array ([fruit] => apple, pear [tree] => bamboo, rich bamboo [Flower] => Chrysanthemum, carnation [others] =>) [animal system] => Array ([land] => Tiger, Lion [Sea] => fish, Seahorse [others] => ))*/
Why can't I find the page?
The webpage cannot be found... it's your server error, or the link is wrong...
The webpage cannot be found... it's your server error, or the link is wrong...
I changed [] to array (). how can I output the output array to the front-end of thinkphp? How to nest volist output
[] Php 5.4 +
Distribute to foreground
$ This-> assign ('data', $ data );
How do I display them cyclically? what style should I add? it's your business.
Http://document.thinkphp1.cn/manual_3_2.html#volist