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

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -