1
我不unserstand为什么我得到这样的错误:非法使用偏移动态变量
警告: 非法偏移类型.../index.php文件上线10美元1.4141
警告:非法上线 偏移类型.../index.php的10日元118.56
这里是我的代码:
<?php
$xml = simplexml_load_file("eurofxref-daily.xml");
$array=array();
foreach ($xml->children() as $cubeMain) {
foreach ($cubeMain->children() as $cubeTime) {
echo "Time: " . $cubeTime['time'];
foreach ($cubeTime->children() as $cubeCurr) {
$currency=$cubeCurr['currency'];
$rate=$cubeCurr['rate'];
$array = array($currency => $rate);
echo $currency . " " . $rate . "<br />";
}
}
}
?>
Ty,但是如何在后面回显键值? – Marko 2011-04-03 08:42:14
你是什么意思?使用对象本身'回显'它们是很好的,因为它们在字符串上下文中使用时正确转换为字符串。你的代码甚至可以做到这一点...... – ThiefMaster 2011-04-03 08:43:12
我的目标是:1)将所有货币汇率转换为数组2)从数组中打印货币和汇率。 – Marko 2011-04-03 08:45:23