How to display specific column from CSV file in php? -
i have 1 csv file has 10 columns(a j). now, problem want display data column name e on screen using php.
how read , display 1 column csv file?
you can use fgetcsv()
function. takes line of csv file , expands array. following script wil print out fourth column of each line of csv file. can change $col
variable print out different column.
<?php //column print, e 5th $col = 5; // open file reading $file = fopen("yourfile.csv","r"); // while there more lines, keep doing while(! feof($file)) { // print out given column of line echo fgetcsv($file)[$col]; } // close file connection fclose($file);
Comments
Post a Comment