请原谅我标题中的双关语(呵呵),但这真的让我发疯了!这是我的代码:
for ($i=0;$i < $a;$i++){
$total = (array)$orders -> Total -> Line[$i];
echo '<pre>';
print_r($total);
echo '</pre>';
}
...它输出以下内容:
Array
(
[@attributes] => Array
(
[type] => Subtotal
[name] => Subtotal
)
[0] => 299.99
)
Array
(
[@attributes] => Array
(
[type] => Shipping
[name] => Shipping
)
[0] => 13.36
)
Array
(
[@attributes] => Array
(
[type] => Tax
[name] => Tax
)
[0] => 0.00
)
Array
(
[@attributes] => Array
(
[type] => GiftCertificate
[name] => Gift certificate discount (117943:@CAC7HXPXFUNNJ3MTGC:63.35 117372:@DK9T9TMTCTCTUWF9GC:250.00)
)
[0] => -313.35
)
Array
(
[@attributes] => Array
(
[type] => Total
[name] => Total
)
[0] => 0.00
)
我的问题是:如何将每个美元金额 [0] 保存到根据数组 ['type'] 命名的相应变量中?