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) {

 

태그: 
sean의 이미지

Language

Get in touch with us

"어떤 것을 완전히 알려거든 그것을 다른 이에게 가르쳐라."
- Tryon Edwards -