Forum Moderators: coopster

Message Too Old, No Replies

Question marks when using getcsv

         

Elric99

7:01 pm on Aug 14, 2007 (gmt 0)

10+ Year Member



Hello,

I'm using PHP to open a .csv file.

The problem is that when I use this code:

$row = 1;
$handle = fopen("$csv", "r");
while (($data = fgetcsv($handle, 1000, ","))!== FALSE) {
$num = count($data);
echo "<p> $num fields in line $row: <br /></p>\n";
$row++;
for ($c=0; $c < $num; $c++) {
echo $data[$c] . "<br />\n";
}
}
fclose($handle);

exit;

There's a question mark in between every letter in the csv returned. This is in firefox. IE shows a space in between.

I think it's something to do with the format of the CSV being in Unicode, but it's a little tricky for me.

Any help very much appreciated.

Tom

eelixduppy

1:29 am on Aug 23, 2007 (gmt 0)



What kind of text editor did you use to format the CSV file?

SteveLetwin

9:43 pm on Aug 23, 2007 (gmt 0)

10+ Year Member



I think it's something to do with the format of the CSV being in Unicode

That's exactly why. It's my understanding that PHP does not currently support Unicode. PHP 6 should, but it's not here yet. So the simplest thing would be to convert the unicode file into plain ol' ASCII. If you'd lose too much data that way, then maybe you should consider a different solution.