Max Bogatec Max Bogatec - 1 year ago 92
MySQL Question

PHP calculate with special chars

I'm working on an function that's getting Data from an Mysql DB and then it should calculate it. I've got the function like i want it, but my only Problem is that my Value in the DB looks like :


But php thinks the dots are commas. So with the formating my result looks like:

25.000,00 + 40.000,00 =65.00

How it should look like:

25.000,00 + 40.000,00 = 65.000,00

I've already tried following parameter:

str_replace(',', '.', $value1);

It didn't work , so I'm asking you guys if someone has a clue how to do this.

My Code:


// Check connection
if (mysqli_connect_errno())
echo "Failed to connect to MySQL: " . mysqli_connect_error();

$result = mysqli_query($con,"SELECT * FROM Fahrzeugverkauf WHERE Fahrzeugkonto = 2");
$rahmen = 230000;
$total3 = $row['EKBrutto'];
$test +=$total3;
$belastung= $rahmen - $test;

//$res1 =



<?php echo "Verfügbarer Rahmen: " .$rahmen;?> <br>
<?php echo "Belastung: " .$test;?> <br>
<?php echo "Verbliebenes Guthaben: " .$belastung;?>

Answer Source

Try it:

setlocale(LC_MONETARY, 'en_US');
echo money_format('%(#10n', $number) . "\n";
// ($        1,234.57)


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download