How to upload and parse a CSV file in php

The Solution to How to upload and parse a CSV file in php is


This can be done in a much simpler manner now.

$tmpName = $_FILES['csv']['tmp_name'];
$csvAsArray = array_map('str_getcsv', file($tmpName));

This will return you a parsed array of your CSV data. Then you can just loop through it using a foreach statement.

~ Answered on 2015-01-09 15:22:21


Most Viewed Questions: