Get csv data without header in PHP

 $filename is containing url or address of csv to read.

/**
 * Csv to array.
 */
function csvtoarray($filename) {
  $header = NULL;
  $data = array();
  if (($handle = fopen($filename'r')) !== FALSE) {
    while (($row = fgetcsv($handle)) !== FALSE) {
      if (!$header) {
        $header = $row;
      }
      else {
        $data[] = $row;
      }
    }
    fclose($handle);
  }
  return $data;
}


Comments