Skip to content

Instantly share code, notes, and snippets.

@RoelofWobben
Created May 12, 2023 08:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RoelofWobben/c037b7f7df1424bb17dc2515bad24391 to your computer and use it in GitHub Desktop.
Save RoelofWobben/c037b7f7df1424bb17dc2515bad24391 to your computer and use it in GitHub Desktop.
<?php
// ONLY FOR TESTING
error_reporting(E_ALL);
function readCsvFile (): array {
$rows = [];
if (($handle = fopen("stock.csv", "r")) !== FALSE) {
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
$rows[] = $data;
}
fclose($handle);
}
return $rows;
};
$data = readCsvFile();
function displayCSVData() {
?>
<div class="phppot-container">
<table class="striped">
<thead>
<tr>
<th>Symbol</th>
<th>Price</th>
<th>Symbol</th>
</tr>
</thead>
<tr class="data">
<?php
foreach ($data as $row) {
?>
<td>
<?php echo $row[0]; ?>
</td>
<td>
<?php echo $row[2]; ?>"<?php echo $row[1]; ?>
</td>
}
</tr>
</table>
</div>
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment