How do I create variables from XML data in PHP?

后端 未结 9 1587
不思量自难忘°
不思量自难忘° 2021-01-25 18:34

Been trying to figure this out for a short while now but having now luck, for example I have an external xml document like this:


&         


        
9条回答
  •  再見小時候
    2021-01-25 18:55

    Use SimpleXML to parse the file into an object/array structure, then simply use list:

    $sxml = new SimpleXMLElement($xml);
    $positions = (array)$sxml->positions->children();
    list($top_a, $top_b, $sidebar_a, $footer_a) = $positions['position'];
    

提交回复
热议问题