The following code can be used to import a CSV file in PHP -
$num fields in line $row:"; $row++; for ($c=0; $c < $num; $c++) { echo $data[$c] . "
"; } } fclose($handle); } ?>
This file will display the contents of the csv file on the screen.
In the above code, starting from line 1 (because line 0 usually contains headers/column names), the csv file is opened in read mode and the fgetcsv function is called to read the 1000 rows of data.
The number of columns in each row is displayed along with its content.
p>
The above is the detailed content of How to import CSV file in PHP?. For more information, please follow other related articles on the PHP Chinese website!