How to convert xml into array in php?

前端 未结 9 1355
半阙折子戏
半阙折子戏 2020-11-22 02:54

I want to convert below XML to PHP array. Any suggestions on how I can do this?


   
     
       

        
9条回答
  •  别那么骄傲
    2020-11-22 03:18

    Surprised no one mentioned xml_parse_into_struct:

    $simple = "simple note";
    $p = xml_parser_create();
    xml_parse_into_struct($p, $simple, $vals, $index);
    xml_parser_free($p);
    echo "Index array\n";
    print_r($index);
    echo "\nVals array\n";
    print_r($vals);
    

提交回复
热议问题