It was all going well until I came across a situation I could not resolve so far. I was unable to adjust the total values of the file.
The example below shows how the value is. And it should stay that way (R $ 335.43). I've tried to insert some codes to change the position of the comma and period, but I was not successful.
Some codes that I put were like this:
echo "Valor: R$ ".number_format($data[5], 0,',','.')
But it did not work. Below is the entire script.
ID: 000001 Month: 06 Year: 2015 Order: 001 Entity: UNIMED EMPRESARIAL (PL ANTIGO) Value: R $ 33,543
<?php
ini_set('display_errors',0);
error_reporting(0);
?>
<?php
$conecta = mysql_connect("localhost","root","");
mysql_select_db("meu_banco_dados",$conecta);
$sql = "INSERT INTO extratos (usuario,senha,mes,ano,ordem,ref,total,cod) values";
$dados = mysql_query("select * from minha_tabela");
$arquivo = fopen("meu_arquivo.txt", "r");
if ($arquivo) {
$total = 0;
while (($line = fgets($arquivo)) !== false) {
$data = explode("|",$line);
echo "ID: ".$data[0]."</br>";
echo "Mês: ".$data[1]."</br>";
echo "Ano: ".$data[2]."</br>";
echo "Ordem: ".$data[3]."</br>";
echo "Entidade: ".$data[4]."</br>";
echo "Valor: R$ ".number_format($data[5], 0,',','.')."</br>";
echo "Cod: ".$data[6]."</br>";
}
echo '</br>Total: R$' . number_format($total, 0,',','.');
fclose($arquivo);
} else {
}
?>