Can anyone share a resource (download or a how-to) for parsing a CSV to an associative array based on the first row of the CSV acting as the column names?

I found this resource http://blog.joshuamcginnis.com/2008/12/csv-to-associate-array/ but can't make heads or tales about the second parameter sent to the function.

In case you're unsure what I am speaking of, look at this.

CSV file
John,Smith,555-1212

would explode to

array (
 [0] => John,
 [1] => Smith,
 [2] => 555-1212
}

With the appropriate script, I want to take

CSV file
firstName,lastName,homePhone
John,Smith,555-1212

would explode to

array (
 [firstName] => John,
 [LastName] => Smith,
 [homePhone] => 555-1212
}

Good of you to take time to read this.

if you KNOW what to expect in cells 0,1,2 etc you can do a for next loop which creates an associative array with the names corresponding to the numeric array.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.