1
如何從XML節點中精確移除不需要的父項並保持數據不變?像陣列移位。 例如,我有一個數組PHP Array - 刪除未鎖定的密鑰+保留數據
[LineItems] => Array
(
[0] => Array
(
[LineItem] => Array
(
[Description] => iPhone
[Quantity] => 1
[UnitAmount] => 101.0000
[AccountCode] => 200
[TaxAmount] => 0.0000
[LineAmount] => 101.0000
)
)
[1] => Array
(
[LineItem] => Array
(
[Description] => Flat Shipping Rate
[Quantity] => 1
[AccountCode] => 200
[UnitAmount] => 5.0000
[LineAmount] => 5.0000
)
)
)
如何確切地除去了LineItem [0]和了LineItem [1]和推的LineItem陣列向左?我在尋找這樣的事情:
[LineItems] => Array
(
[LineItem] => Array
(
[Description] => iPhone
[Quantity] => 1
[UnitAmount] => 101.0000
[AccountCode] => 200
[TaxAmount] => 0.0000
[LineAmount] => 101.0000
)
)
[LineItem] => Array
(
[Description] => Flat Shipping Rate
[Quantity] => 1
[AccountCode] => 200
[UnitAmount] => 5.0000
[LineAmount] => 5.0000
)
)
此外,轉換陣列狀時:
Array
(
[Invoices] => Array
(
......something....
)
)
當轉換爲XML,XML將輸出
<?xml version="1.0" encoding="UTF-8"?>
<root>
<Invoices>
</Invoices>
</root>
我如何實際上刪除根?
在此先感謝。
我期待這樣的事情 - > http://pastebin.com/raw.php?i=3R08esvr – MrYanDao
這是不可能的,你不能有重複的鍵... –
正如onetrickpony所說,你不能有這樣的重複鍵。你想使用'Description'作爲鍵嗎? – Barmar