90% of my website pages use the utf8 encoding feature for compile an DataTable.
$a[] = array_map('utf8_encode', $item);
With the old version 8.0 of php everything was fine, in the new version it gives me an error when a value of $item ($item is an array) is null.
What is a valid alternative?
3
Answers
I just do this before array_map('utf8_encode', $item):
and it works good.
Use mb_convert_encoding to convert from ISO-8859-1 to UTF-8
Example:
We know that
utf8_encode
is deprecated since PHP 8.2.0 and will be removed in PHP 9 https://php.watch/versions/8.2/utf8_encode-utf8_decode-deprecatedSo the alternative can be:
Documentation:
https://www.php.net/manual/de/function.mb-detect-encoding.php