所以我有以下工作代码:
$arrayitertest=Array("Fruit"=>Array("Pear","Peach","Apple","Banana"),"Cars"=>Array("My budget","other cars."));
foreach ($arrayitertest as $key=>$value)
foreach($arrayitertest[$key] as $result) echo $key.":". $result."|";
但是当我改变它foreach ($arrayitertest as $key => $value)
时foreach ($arrayitertest as $key)
会引发一个致命错误(尽管我从未使用过 $key 变量。)
错误是:为 foreach() 提供的参数无效
有人可以告诉我为什么会这样吗?
编辑:哇,感谢所有答案....不过,我会接受目前最具体的答案。