php - Looping through a csv with fgetcsv -
i have csv file 3 columns: email address, first name , last name. have got stage can print out array using following code:
<?php $file = fopen("testemails.csv","r"); while(! feof($file)) { print_r(fgetcsv($file)); } fclose($file); ?>
this prints array, every field in row. want print purely values in first column of row. how done, documentation on fgetcsv seems sketchy me (a relative beginner).
thanks.
the first example in fgetcsv
documentation contains nuggets of need.
http://php.net/manual/en/function.fgetcsv.php
while (($data = fgetcsv($file)) !== false) { echo "email address " . $data[0]; }
fgetcsv
returns numerically indexed array of representing columns, want print first column.
Comments
Post a Comment