Voting

: four minus four?
(Example: nine)

The Note You're Voting On

lewiscowles at me dot com
5 years ago
In-case anyone is having difficulty working around Byte-order-marks, the following should work. As usual no warranty, you should test your code... It's for UTF-8 only

<?php

//...

$fh = fopen('wut.csv', 'r');
$firstThreeBytes = fread($fh , 3);
if(
$firstThreeBytes !== "\xef\xbb\xbf") {
rewind($fh);
}
while((
$row = fgetcsv($fh, 10000, ',')) !== false) {
// Your code here
}

This basically reads 3 bytes and checks if they match

https://en.wikipedia.org/wiki/Byte_order_mark has more information if you are dealing with other code-pages

<< Back to user notes page

To Top