我有一個產品數組其名稱爲$項目在PHP通整個陣列中的另一個陣列
Array
(
[0] => Array
(
[Quantity] => 2
[Product] => Array
(
[Name] => Barbula klandoa - Caryopteris clandonensis
[UnitPrice] => Array
(
[Gross] => 1480
[Net] => 0
[Tax] => 0
[TaxRate] => 0
[CurrencyCode] => PLN
)
)
)
[1] => Array
(
[Quantity] => 1
[Product] => Array
(
[Name] => Aronia czarnoowocowa Nero - Aronia melanocarpa Nero
[UnitPrice] => Array
(
[Gross] => 1200
[Net] => 0
[Tax] => 0
[TaxRate] => 0
[CurrencyCode] => PLN
)
)
)
[2] => Array
(
[Quantity] => 1
[Product] => Array
(
[Name] => Ambrowiec Amerykański P9 - Liquidambar styraciflua
[UnitPrice] => Array
(
[Gross] => 1300
[Net] => 0
[Tax] => 0
[TaxRate] => 0
[CurrencyCode] => PLN
)
)
)
)
人無我有把它傳遞給這個:
$shoppingCart = array(
'GrandTotal' => ($suma_z_produktow*10),
'CurrencyCode' => 'PLN',
'ShoppingCartItems' => array (
array ('ShoppingCartItem' => $item)
)
);
結果是隻有最後一個條目從這個數組傳遞給這個新的數組。 我可以nodifi它,並將它傳遞這樣的:
$shoppingCart = array(
'GrandTotal' => ($suma_z_produktow*10),
'CurrencyCode' => 'PLN',
'ShoppingCartItems' => array (
array ('ShoppingCartItem' => $item[0)
array ('ShoppingCartItem' => $item[1)
)
);
該方法的工作,但我不知道有多少產品將客戶的訂單。是否有任何方法可以通過一行中的所有項目?
它用於Payu支付方法集成。 THX
你試過implode()嗎? – Robert