我有一个关于 php 中的变量类型的简单问题。我的数组中有两个值:
$row['DS'] // type :float (with one decimal like 12.2)
$row['TC'] // type :float (with one decimal like 24.2)
在进行以下计算时,我实际上尝试做的是:
$row['TC'] / $row['DS'] // $row['DS'] need to be as integer (without point,like 12)
结果应该是两位小数,如(2.32)。我试着那样做
$DSF = number_format($row['DS'],0);
$ConF = $row['TC'] / $DSF ;
echo number_format($conF,2);
但它返回错误的结果。例如 :
$row['DS'] = 59,009.3 ---> after change the format is change to 59,009
$row['TC'] = 190.0
$ConF = 190.0 / 59,009
它应该是 000.223 (这个数字附近的东西),我希望得到 0 (在我改变格式之后, number_format($conF,2)
但程序不是这个,而是返回数字 3.22 我做错了什么?