Home > Article > Backend Development > Problems encountered when Array2XML converts arrays into XML format
I recently developed a project that required calling a third-party interface. The data provided by the third party was xml. I directly used Array2XML to convert the php array into XML format.
XML format such as:
<root> <body> <item></item> <item></item> <item></item> </body></root>
Since the PHP array cannot specify multiple repeated subscripts, the latter ones will overwrite the previous values, and only one value will be displayed in the end
= 'body' =>
The above php array is converted into XML using Array2XML, and there will only be one item node in the body.
Here you can write the PHP array in the default format without using multi-dimensional key and value formats.
='body' =>'item' =>
Put all item nodes in it as an array without writing key => value, so Array2XML will use the item node to generate multiple item nodes.
The above is the detailed content of Problems encountered when Array2XML converts arrays into XML format. For more information, please follow other related articles on the PHP Chinese website!