Last active
April 26, 2022 02:24
-
-
Save teolopez/d16fe097b869afc71e2f to your computer and use it in GitHub Desktop.
fgetcsv – csv to html table
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<table class="table table-bordered table-condensed table-hover"> | |
<?php | |
$row = 1; | |
ini_set('auto_detect_line_endings',TRUE); | |
if (($handle = fopen("http://docs.shopify.com/manual/your-store/products/product_template.csv", "r")) !== FALSE) { | |
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { | |
$num = count($data); | |
echo "<tr>"; | |
for ($c=0; $c < $num; $c++) { | |
if ($row == 1) { | |
echo "<th>" . $data[$c] . "</th>\n"; | |
} else { | |
echo "<td>" . $data[$c] . "</td>\n"; | |
} | |
} | |
echo "</tr>\n"; | |
$row++; | |
} | |
ini_set('auto_detect_line_endings',FALSE); | |
fclose($handle); | |
} | |
?> | |
</table> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment