Enter your keyword

Blog

How to get CSV File Data in Php

$file_name = 'samplefile.csv';
 $row = 0;
if (($handle = fopen($file_name, "r")) !== FALSE) {
	 echo '<table>';
        while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
        if($row == 0){ 
            $row++; 
            } else {
        echo '<tr>';
          echo '<td>'.$data[0].'</td>';
        echo '<td>'.$data[1].'</td>';
        echo '<td>'.$data[2].'</td>';
        echo '<td>'.$data[3].'</td>';
        echo '</tr>';
        }
}
    echo '</table>';
    } else {
    echo 'File could not be opened.';
    }	
    fclose($handle);

No Comments

Add your review

Your email address will not be published.

* Feilds are Required.