I want to delete the BOM from my imported file, but it just doesn\'t seem to work.
I tried to preg_replace(\'/[\\x00-\\x1F\\x80-\\xFF]/\', \'\', $file);
Correct way is to skip BOM if present in file (https://www.php.net/manual/en/function.fgetcsv.php#122696):
ini_set('auto_detect_line_endings',TRUE);
$file = fopen($filepath, "r") or die("Error opening file");
if (fgets($file, 4) !== "\xef\xbb\xbf") //Skip BOM if present
rewind($file); //Or rewind pointer to start of file
$i = 0;
while(($line = fgetcsv($file, 1000, ";")) !== FALSE) {
...
}