Reading CSV file with newline as delimiter - PHP
I got some issues working with a CSV file with newline delimeter. I want to read the file and be able to process the content. I was so confused what the deliter would look like. After solving this I decided to share with everyone who has this same problem. I guess this would save somebody some from sleepless night.
Below is the code that did the magic.
//CSV file
$csvFile = "upload/file.csv";
//read the content of the file
$contents = file_get_contents($csvFile);
//read the CSV file with delimiter
$data = str_getcsv($contents, "\r\n");
foreach($data as $row){
//process the content here
}
Hope this helps someone.