I hope you can help me out with this problem I have with xml2array. when there is one item in the XML it returns just the array (example 1), when there are multiple items it returns an extra dimension 0,1,2,3 (example 2). I don't want to have two sets of foreach code for 1 and many arrays.
How do I can convert example 1 into example 2? [line][0]? I tried simply adding it to the existing array but then how do I remove the old one?
EXAMPLE 1
[line] => Array
(
[lineno] => 1
[partno] => 1234
[desc] => Furniture
[qty] => 1.00
)
EXAMPLE 2
[line] =>[0] => Array
(
[lineno] => 2
[partno] => 1234
[desc] => Furniture
[qty] => 1.00
)
[1] => Array
(
[lineno] => 1
[partno] => 1234
[desc] => Furniture
[qty] => 1.00
)