PHP数组操作问题Variable passed to each() is not an array or object$price=array('tires'=>100);$price['oil'] =99;$price['spark plug']=50;$price['test']=100;while(list($product,$price)=each($price))echo $product.'-'.$price.'';ERROR:Variable passed

来源:学生作业学帮网 编辑:学帮网 时间:2024/05/04 09:19:59

PHP数组操作问题Variable passed to each() is not an array or object
$price=array('tires'=>100);$price['oil'] =99;$price['spark plug']=50;
$price['test']=100;
while(list($product,$price)=each($price))
echo $product.'-'.$price.'
';
ERROR:Variable passed to each() is not an array or object

你的list中用了相同的price变量名导致你的price数组被赋值覆盖了.把list中的price改个名字.
==========
$price=array('tires'=>100);$price['oil'] =99;$price['spark plug']=50;
$price['test']=100;
while(list($product,$price_1)=each($price))
echo $product.'-'.$price_1.'
';