Array2XML-重复的标记名称将被忽略


Array2XML - Duplicated tags names are being ignored

我使用Array2XML和PHP从数组创建XML。

以下是重复标签的代码:

"positions" => array(
   "position" => "top_centre",
   "position" => "centre_left",
   "position" => "centre_right",
   "position" => "bottom_centre"
);

我可以看到这里的问题是值被覆盖,所以XML显示如下:

  <positions>
    <position>bottom_centre</position>
  </positions>

如何使用Array2XML将其显示为这样?:

<positions>
   <position>top_centre</position>
   <position>centre_left</position>
   <position>centre_right</position>
   <position>bottom_centre</position>
</positions>


编辑:修复了这个问题,只需要使用另一个数组:

"positions" => array(
   "position" => array("top_centre", "centre_left", "centre_right", "bottom_centre")
)

修复了这个问题,只需要使用另一个数组:

"positions" => array(
   "position" => array("top_centre", "centre_left", "centre_right", "bottom_centre")
)