0
對於電子商務,即預期名稱值對我有以下批准代碼:PHP多維數組名稱值對
功能create_example_purchase(){
set_credentials();
$purchase = array(
'name' => 'Digital Good Purchase Example',
'description' => 'Example Digital Good Purchase',
'amount' => '12.00', // sum of all item_amount
'items' => array(
array(// First item
'item_name' => 'First item name',
'item_description' => 'a description of the 1st item',
'item_amount' => '6.00',
'item_tax' => '0.00',
'item_quantity' => 1,
'item_number' => 'XF100',
),
array(// Second item
'item_name' => 'Second Item',
'item_description' => 'a description of the 2nd item',
'item_amount' => '3.00',
'item_tax' => '0.00',
'item_quantity' => 2,
'item_number' => 'XJ100',
),
)
);
return new Purchase($purchase);
}
我想從運輸車中動態獲取關聯$購買陣列中的$ items數組。
有沒有一種方法來生成正上方相同的輸出?
我的骯髒的解決方案,寫$ purchase數組作爲包含文件中生成的$ items數組的字符串,並在稍後將其包含在被調用的腳本中 。
幫助讚賞。
謝謝creminsn,產量雖然有所不同。 當我將數組重命名爲$ purchase ['items']時,輸出 將更加類似。問題輸出必須相同才能被接受。 – 2012-04-06 13:01:01