Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TCPDF errors on PHP 7

Tags:

php

php-7.2

tcpdf

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
like image 764
Nashir Avatar asked Dec 13 '22 15:12

Nashir


2 Answers

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

like image 92
Sebastian Schmal Avatar answered Dec 17 '22 22:12

Sebastian Schmal


Note to anybody that finds this...the latest version of TCPDF has this fixed...so if you simply do an update you should be ok: https://github.com/tecnickcom/TCPDF

like image 36
user2662680 Avatar answered Dec 18 '22 00:12

user2662680