Closed
Description
Description
Does not occur in PHP8.0
The following code is slow when updated to PHP8.1
The functions used are below
- strlen
- mb_convert_encoding
- str_replace
The following code:
3500 data are set in $data
In PHP8.0 it takes 2 seconds to complete. It takes 3 minutes with PHP8.1
<?php
foreach ($data as $record) {
$csvData = array();
foreach (array_values((array)$record) as $item) {
if (strlen($item) !== strlen(mb_convert_encoding(mb_convert_encoding($item, 'SJIS-win', 'UTF-8'), 'UTF-8', 'SJIS-win'))) {
$notExistsUnicodeValues[] = $item;
} else {
$csvData[] = str_replace(array("\r\n", "\r", "\n"), "\n", $item);
}
}
}
PHP Version
PHP 8.1.0
Operating System
・Ubuntu 20.04
・CentOS Linux release 7.9.2009
・