Dear, I have the following code, where I read a .CSV file and show it in a table. It even does the proposed, however I get the error Notice: Undefined offset: 1
at the end of the file. This for all arrays, minus 0
How to resolve this error?
<table id="data-table" class="table table-striped table-bordered">
<thead>
<tr>
<th>ID</th>
<th>Nome</th>
<th>Usuário</th>
<th>Email</th>
<th>Perfil</th>
</tr>
</thead>
<tbody>
<?php
$linhas = fopen ("teste.csv", "r");
while (!feof ($linhas))
{
$ponteiro = fgets($linhas, 4096);
$valores = preg_split("[;]",$ponteiro);
echo "<tr>";
echo "<td>".$valores[0]."</td>\n
<td>".$valores[1]."</td>\n
<td>".$valores[2]."</td>\n
<td>".$valores[3]."</td>\n
<td>".$valores[4]."</td>\n
<td>".$valores[5]."</td>\n";
echo "</tr>";
}
fclose ($linhas);
echo "</table>";
?>
</tbody>
</table>