I have a CSV file that I need to import into an associative array. The data looks like this:
"General Mills Cereal",http://sidom.com/dyn_li/60.0.75.0/Retailers/Saws/120914_20bp4_img_8934.jpg,$2.25,"9-17.12 oz., select varieties","Valid Sep 14, 2012 - Sep 20, 2012",Saws,"Grocery"
I wan to transform this data into an array where I can grab values like this:
$items[$row]['title'];
$items[$row]['imgurl'];
$items[$row]['itemprice'];
$items[$row]['itemsize'];
$items[$row]['expir'];
$items[$row]['storename'];
$items[$row]['storetype'];
Where the elements above correspond to my CSV file. How can I import this file into such an array?
I would suggest using the built-in function fgetcsv
There's a simple usage example there also.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With