PHP Fatal error: Uncaught Error: Call to undefined function each() in /

All your question about php
Post Reply
mister_v
Posts: 203
Joined: Thu Mar 04, 2010 9:19 pm

PHP Fatal error: Uncaught Error: Call to undefined function each() in /

Post by mister_v »

Got the following error for an old script:

Code: Select all

 PHP Fatal error:  Uncaught Error: Call to undefined function each() in /file.php
mister_v
Posts: 203
Joined: Thu Mar 04, 2010 9:19 pm

Re: PHP Fatal error: Uncaught Error: Call to undefined function each() in /

Post by mister_v »

The script still uses statements like:

Code: Select all

while ( list ($key,$val) = each ($array) )
{
This an old way of doing things ( in PHP 6 ?)
Anyway in PHP8.1 the function each() has been removed.

I recommand replacing it with foreach()

Code: Select all

foreach($array as $key=>$val)
{
...
}
Did it in my script and now it is running properly again.
Post Reply