TCPDF errors on PHP 7

Nashir picture Nashir · Jul 28, 2018 · Viewed 9.5k times · Source

I'm using TCPDF plugin to generate the PDF in PHP 7. The same code is working fine in the lower version PHP 5 but when I run this same code in the PHP 7 it's giving the below error message.

A PHP Error was encountered Severity: 8192

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

Filename: tcpdf/tcpdf.php

Line Number: 16542

Answer

Sebastian Schmal picture Sebastian Schmal · Feb 20, 2019

Edit in File: \FPDI\fpdi.php the Line 567:

//while (list($k, $v) = each($value[1])) {

in Code: foreach ($value[1] AS $k => $v) {

And edit in File: \tcpdf\tcpdf.php the Line 16543:

//while (list($id, $name) = each($attr_array[1])) {

in Code: foreach($attr_array[1] as $id => $name) {