I know about fgetcsv, but it doesn't really do what I'm looking for.
I have the following csv file:
productId,productName,productActive
1,test product,1
2,test product2,0
I'm looking for something that will create an array that looks like this:
array (0)
['productId'] => 1
['productName'] => test product
['productActive'] => 1
array (1)
['productId'] => 2
['productName'] => test product2
['productActive'] => 0
any ideas?
fgetcsvwill serve you well in this situation. Read the first line, gather field names, then read the remaining lines and collect them into the array using the field names as keys.