如何使用php从xml获取标签的属性作为键和值

时间:2018-10-23 11:07:15

标签: php arrays xml

我必须使用php将数组转换为xml。

下面是我的xml

<custom-attributes>
  <custom-attribute dt:dt="int" name="Attr_New">0</custom-attribute>
  <custom-attribute dt:dt="date" name="Attr_New_Date">20150601</custom-attribute>
  <custom-attribute dt:dt="string" name="Attr_Base_SKU">314100822304</custom-attribute>

我想要如下输出,

[custom-attribute] => Array
(
    [Attr_New] => 0
    [Attr_New_Date] => 20150601
    [Attr_Base_SKU] => 314100822304
)

但是Iam变得像下面一样,

[custom-attribute] => Array
(
    [0] => 0
    [1] => 20150601
    [2] => 314100822304
)

请帮助我某人

0 个答案:

没有答案