I'm trying to remove the last comma from an Array but I can not.
I have a CSV file in which I read and retrieve an array with a code to be used in a Where of a sql Query. I am using substr ($ number_Aut, 0, -1) but it is not working.
Follow the code:
<?
while(! feof($CSVfp)) {
$data = fgetcsv($CSVfp, 1000, ";");
$number_Aut = "'$data[13]','"; //Pego o código desejado no arquivo CSV e adiciono Aspas simples e virgula
if ($data[13] != '') { //Verifico se entre as aspas não tem campos Vazios
echo substr($number_Aut,0,-1); //Elimino a ultima virgula do ARRAY MAS NÃO ESTÁ FUNCIONANDO
}
?>
<tr>
<td align="center"><?php echo date('d/m/Y', strtotime($data[4])); ?></td>
<td align="center"><?php echo $data[11]; ?></td>
<td align="center"><?php echo $data[13]; ?></td>
<td align="center"><?php echo $data[2]; ?></td>
<td align="center"><?php echo $data[9]; ?>/<?php echo $data[10]; ?></td>
<td align="center"><?php echo number_format( $data[8], 2, ',', '.'); ?></td>
<td align="center"><?php echo number_format( $data[17], 2, ',', '.'); ?></td>
</tr>
<?php
}
?>