1 (edited by cleal 10/26/2018 06:49:23 pm)

Topic: The each() function is deprecated TCPDF

When I try to create reports, I have the error

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

I tried to implement new versión of TCPDF, but I failed.  Someone have the same problem? or How I fix that.

Thanks.

cleal

Re: The each() function is deprecated TCPDF

Are you using PHP7 ?

Phuong

3 (edited by notrinos 10/25/2018 02:02:29 pm)

Re: The each() function is deprecated TCPDF

Since php version 7.2 the each() function is deprecated
Find all while loop with each() function in the reporting/includes/tcpdf.php and modify them to foreach loop.
Example:

while (list($id, $name) = each($attr_array[1])) {
    $dom[$key]['attribute'][strtolower($name)] = $attr_array[2][$id];
}

need to be

foreach ($attr_array[1] as $id => $name) {
    $dom[$key]['attribute'][strtolower($name)] = $attr_array[2][$id];
}
Phuong

Re: The each() function is deprecated TCPDF

Thank you so much!!!

Very useful.

cleal

Re: The each() function is deprecated TCPDF

I will try to catch these and replace.

Joe

Re: The each() function is deprecated TCPDF

Now works without errors!

Thank you...

cleal

Re: The each() function is deprecated TCPDF

There are 4 matches in reporting/includes/tcpdf.php (committed) and 1 in reporting/includes/fpdi/fpdi. (line 396).

The foreach() construct has been in existence for quite a while, the each() was convenient as an all-in-one list() assignment as well. PHP 7.2+ seems to be reducing alternative coding constructs as part of their "standardisation".

8 (edited by cleal 10/26/2018 06:49:38 pm)

Re: The each() function is deprecated TCPDF

Thank you for that tip, I already made the change.

cleal