我正在从一个MySQL数据库获取数据的函数,然后它应该计算它。我已经得到了功能像我想的那样,但我的唯一的问题是,我在数据库中值的样子:PHP与特殊字符计算
€12.345,67
但是PHP认为点是逗号。因此,与格式化我的结果是这样的:
25.000,00 + 40.000,00 = 65.00
如何它应该看起来像:
25.000,00 + 40.000,00 = 65.000,00
我已经试过以下参数:
str_replace(',', '.', $value1);
它没有工作,所以我问如果有人有线索如何做到这一点。
我的代码:
<?php
$con=mysqli_connect("localhost","root","pass","DB-Nane");
// 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;
while($row=mysqli_fetch_array($result)){
$total3 = $row['EKBrutto'];
$test +=$total3;
$belastung= $rahmen - $test;
}
//$res1 =
mysqli_close($con);
?>
<?php echo "Verfügbarer Rahmen: " .$rahmen;?> <br>
<?php echo "Belastung: " .$test;?> <br>
<?php echo "Verbliebenes Guthaben: " .$belastung;?>
你试过到u你可以使用'number_format()'函数吗? – SuperDJ
还没有,我会试试看! –
尝试它: http://php.net/manual/es/function.money-format.php – Vitorlui