Can someone kindly provide code to create an array from a CSV file using fgetcsv?
I used the following code to create an array from a simple CSV file, but it does not work correctly if one of my fields has multiple commas - for example, addresses.
$lines =file('CSV Address.csv'); foreach($lines as $data) { list($name[],$address[],$status[]) = explode(',',$data); }
* In addition, the str_getcsv function is not supported by my hosting service.
The above code does not work with the following example CSV file. The first column is the name, the second column is the address, the third is family.
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
arrays php csv
Thomas Aug 13 '09 at 1:18 2009-08-13 01:18
source share