PHP code to read CSV file

WBOY
Release: 2016-07-25 08:42:43
Original
909 people have browsed it
  1. function readCSV($csvFile){
  2. $file_handle = fopen($csvFile, 'r');
  3. while (!feof($file_handle) ) {
  4. $line_of_text[] = fgetcsv($file_handle, 1024);
  5. }
  6. fclose($file_handle);
  7. return $line_of_text;
  8. }
复制代码

用法:

  1. $csvFile = "test.csv";
  2. $csv = readCSV($csvFile);
  3. $a = csv[0][0]; // This will get value of Column 1 & Row 1
  4. ?>
复制代码

CSV, PHP


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template