The each() function is deprecated. This message will be suppressed on further calls
The each() function is deprecated. This message will be suppressed on further calls
php7.2以上版本已经废除了each()方法,项目中用到的地方会出现以下报错。
$fruits[0]["fruit"] = "lemons";
$fruits[1]["fruit"] = "apples";
$fruits[2]["fruit"] = "grapes";
usort($fruits, array('\app\index\controller\Index','cmps'));
while (list($key, $value) = each($fruits)) {
echo "$fruits[$key]: " . $value["fruit"] . "\n";
}
使用foreach替换while,不使用list函数处理
foreach($fruits as $key=>$value) {
echo $key.':'.$value["fruit"] . "\n";
}
返回结果
0:apples
1:grapes
2:lemons
转载注明:
感谢博主,喝杯咖啡~
感谢博主,喝杯咖啡~
还没有人发表评论