Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The each() function is deprecated. This message will be suppressed on further calls PHP 7.2 [duplicate]

Tags:

php

I have the below each() line in a PHP file on a server where I recently upgraded the PHP version from 5 to 7.

while(list($file, $info) = each($this->images))

The error below is thrown by the web server after the restart.

The each() function is deprecated. This message will be suppressed on further calls

What will be the correct way of re-writing the above line of code in PHP 7.2?

Thank you.

like image 444
BBT Avatar asked Jul 11 '18 06:07

BBT


1 Answers

You should be able to swap out your each for a foreach in the most part.

<?php

foreach($this->images as $file => $info) {
    // ...
}
like image 164
Progrock Avatar answered Sep 17 '22 11:09

Progrock