简体   繁体   中英

to read a csv file in php and make listing of the content

I have just uploaded a csv file and it is stored in the harddrive of my local system and i want to display all the content of the last uploaded csv file in a table in the same ctp page through which i have uploaded the file.Please kindly help me to do this. Thanks in advance

$rowseparator = "\n";
$columnseparator = ",";
$filename = "path/to/your/file.csv";
$rawdata = file_get_contents($filename);
foreach (explode($rowseparator, $rawdata) as $row) {
    foreach (explode($columnseparator, $row) as $column) {
        // you now know what to do
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM