Skip to content

Instantly share code, notes, and snippets.

@cookpete
Last active October 11, 2015 10:28
Show Gist options
  • Save cookpete/3845321 to your computer and use it in GitHub Desktop.
Save cookpete/3845321 to your computer and use it in GitHub Desktop.
Convert CSV to HTML table
function csv2table($file, $delimiter = ','){
$handle = fopen($file, 'r');
while($line = fgetcsv($handle)) $str .= '<tr><td>'.implode('</td><td>', $line).'</td></tr>';
fclose($handle);
return '<table>'.$str.'</table>';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment