I have a script which combines a number of files into one, and it breaks when one of the files has UTF8 encoding. I figure that I should be using the utf8_decode()
function when reading the files, but I don't know how to tell which need decoding.
My code is basically:
$output = '';
foreach ($files as $filename) {
$output .= file_get_contents($filename) . "\n";
}
file_put_contents('combined.txt', $output);
Currently, at the start of a UTF8 file, it adds these characters in the output: