PHP 7.2 Deprecated each() function

each() loop function is deprecated since PHP 7.2 so that you can update syntax below:

Case 1: without value

reset($array);
while (list($key, ) = each($array)) {

Update to

foreach(array_keys($array) as $key) {

Case 2: without key

reset($array);
while (list(, $value) = each($array)) {

Update to

foreach($array as $value) {

Case 3: key and value

reset($array);
while (list($key, $value) = each($array)) {

Update to

foreach($array as $key => $value) {

 

Tags: 
sean's picture

Language

Get in touch with us

"If you would thoroughly know anything, teach it to other."
- Tryon Edwards -