2

I am getting data from a db table which was in array. So i am using the below code to write that data into csv . in the array we will have some data related to utf-8. But i need the file encoding type should be ANSI. Because the other side system will accept only ANSI encoding files. Below is my code.

$fh = fopen($new_file, 'w+');
header('Content-Encoding: Windows-1252');
header('Content-Type: text/csv; charset=Windows-1252');
foreach($input as $curl_response)
{
    fputs($fh, implode($curl_response, ';')."\n");
}
// ... close the "file"...
fclose($fh);

After generating csv file when i open that in notepad and choose save as option it is showing me as UTF-8. Where i am doing wrong. Any help would be greatly appreciated.

JosefZ
  • 28,460
  • 5
  • 44
  • 83
user3408779
  • 981
  • 2
  • 19
  • 43

0 Answers0