I am creating xml file from array. I found the link How to convert array to SimpleXML and tried creating xml using ans provided by user Hanmant.
Input array
$data = array(
'Pieces' => array(
'Piece' => array(
array(
'PieceID' => '1',
'Weight' => '0.5',
),
array(
'PieceID' => '2',
'Weight' => '2.0',
),
),
),
);
But I am getting result as
<Pieces>
<Piece>
<item0>
<PieceID>1</PieceID>
<Weight>0.5</Weight>
</item0>
<item1>
<PieceID>2</PieceID>
<Weight>2.0</Weight>
</item1>
</Piece>
</Pieces>
How can i get result like
<Pieces>
<Piece>
<PieceID>1</PieceID>
<Weight>0.5</Weight>
</Piece>
<Piece>
<PieceID>2</PieceID>
<Weight>2.0</Weight>
</Piece>
</Pieces>