each() Has Been Removed¶
The each() function has been deprecated in PHP 7.x, and removed in PHP 8.0. Use foreach() instead.
PHP code¶
<?php
$array = ['a' => 1];
list($a, $b) = each($array);
echo $a;
echo $b;
?>
Before¶
PHP Deprecated: The each() function is deprecated. This message will be suppressed on further calls
Deprecated: The each() function is deprecated. This message will be suppressed on further calls
a1
After¶
PHP Fatal error: Uncaught Error: Call to undefined function each()
Fatal error: Uncaught Error: Call to undefined function each()
PHP version change¶
This behavior changed in 8.0