On Wed, Feb 20, 2008 at 9:50 PM, Chris <dmagick@xxxxxxxxx> wrote: > > > Back to my 'original' problem/question, if I '$f = fopen("$file", > > "r")' and 'while ($data = fgets($f))' on the above first format and do > > a $data = str_replace("\t",",",$data); the resulting file looks like > > the second example above when opened into Textpad but will not open > > into separate columns when opened with Excel. > > Look up http://www.php.net/fgetcsv > > and pass "\t" as the field separator. > I give up :-( My script was using fgetcsv() with ',' as delimiter quite happily for 3 years before the 3rd party changed to Cognos. I have a problem with file encoding and I really don't understand enough about that. The files are (I'm told) sent to me in UTF-8 multibyte. My PHP scripts can't read them correctly so I tried using utf8_encode which made slight progress (individual fields recognised in delimited file) but then comparing a utf8_encoded string with one obtained from MySQL then causes problems, such that utf8_encoded "PRIVATE" does not equal MySQL sourced "PRIVATE". The amount of time I'm 'wasting' with this problem will soon exceed that required to manually convert my 100+ files so it's going on teh "to do" list and maybe I'll revisit it at a later date. -- Graham -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php