Can someone kindly provide a code to create an array from a CSV file using fgetcsv?
I've used the following code to create an array from a simple CSV file, but it doesn't work right when one of my fields has multiple commas - such as addresses.
$lines =file('CSV Address.csv');
foreach($lines as $data)
{
list($name[],$address[],$status[])
= explode(',',$data);
}
*Also, str_getcsv is not supported by my hosting service.
The above code doesn't work with the following CSV file example. First column is name, second column is address, third column is marital status.
Scott L. Aranda,"123 Main Street, Bethesda, Maryland 20816",Single
Todd D. Smith,"987 Elm Street, Alexandria, Virginia 22301",Single
Edward M. Grass,"123 Main Street, Bethesda, Maryland 20816",Married
Aaron G. Frantz,"987 Elm Street, Alexandria, Virginia 22301",Married
Ryan V. Turner,"123 Main Street, Bethesda, Maryland 20816",Single