0
Everything was going fine until I came across a situation I couldn’t resolve so far. I couldn’t adjust the total values of the file.
The example below shows how it is. And should look like this (R$ 335,43). I tried to insert some codes to change the position of the comma and the dot, but I was unsuccessful.
Some codes you put were like this:
echo "Valor: R$ ".number_format($data[5], 0,',','.')
but it didn’t work. Below is the whole script.
ID: 000001 Mothers: 06 Year: 2015 Order: 001 Entity: UNIMED ENTERPRISE (OLD PLAN) 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 {
}
?>
The problem is only to format the value as money?
– rray
what is the file value and how do you want it to look? 33,543 is equal to 33,543
– Marcelo Bonus
Number formatting
– rray
The amount has to be R $ 335,43.
– João Freitas