Each()函数已经被弃用了,不建议在新的PHP版本中使用。可以将Each()函数替换为foreach()循环来解决该问题。下面是示例代码:
$colors = array('red', 'green', 'blue'); reset($colors); // 将数组指针重置为第一个元素 while (list($key, $value) = each($colors)) { // 使用each()函数遍历数组 echo "Key: $key; Value: $value\n"; }
可以改写为:
$colors = array('red', 'green', 'blue'); reset($colors); // 将数组指针重置为第一个元素 foreach ($colors as $key => $value) { // 使用foreach()循环遍历数组 echo "Key: $key; Value: $value\n"; }