Search the Community
Showing results for tags 'convert text file'.
Found 1 result
Hi all, I upload a text file to extract info to put into my database on GoDaddy and when I run my php code on it, it tells me that it can't read the file because it is in ansi-xxxx format. In my php code I'm using $var = fgets() to read each line and then put the $vars into the correct table of the database. So I have clicked the button at the top of the code editor and converted the text file to utf-8 - but the conversion leaves the file with 2 odd characters at the beginning of the file and puts a blank line between each line. When I delete the 2 characters and the blank lines and I run my code, everything works as it should and updates my tables. My question is: Can I do a conversion on the ANSI text file using php without any manual manipulating? I've read about the utf-8_encode(), but it says it encodes an ISO-8859-1 file, but mine is an ANSI, or is the ISO-8859-1 an umbrella to a lot of different codes? Can I convert the whole file at once or do i set up a loop to read a line, convert it and write to a new file? Am I interpreting this correctly? I'd appreciate a code snippet so I can see how to set it up - or a reference to more reading so I can learn. Thank you very much!