$invoiceTotal = $settings['Setting']['currency'] . $thisInvoice['Invoice']['invoice_total'];
$bedrag = $settings['Setting']['currency'] . number_format($thisInvoice['Payment']['0']['amount'], 2, '.', ',');
$openbedrag = $invoiceTotal - $bedrag;
//$invoiceTotal = 2
//$bedrag = 1
为什么$openbedrag = $invoiceTotal - $bedrag;
无效?
这是一个简单的计算,为什么它不计算这个变量?
输出0 -_-'
更新问题
$invoiceTotal = $settings['Setting']['currency'].$thisInvoice['Invoice']['invoice_total'];
$bedrag = $settings['Setting']['currency'].number_format($thisInvoice['Payment']['0']['amount'], 2, '.', ',');
$openbedrag2 = $thisInvoice['Invoice']['invoice_total'] - $thisInvoice['Payment']['0']['amount'];
$openbedrag = $settings['Setting']['currency'].$openbedrag2;
货币集€
答案 0 :(得分:1)
您需要对原始数字进行算术运算,而不是格式化数字。
$openbedrag = $thisInvoice['Invoice']['invoice_total'] - $thisInvoice['Payment']['0']['amount'];
答案 1 :(得分:0)
转换为整数: -
$openbedrag = ($invoiceTotal * 1.0) - ($bedrag * 1.0);
答案 2 :(得分:0)
如果 $ settings ['Setting'] ['currency'] 此包含符号,则请避免使用 $ settings ['Setting'] ['currency'] 你的计算时间。所以你的计算如下: -
$invoiceTotal = $thisInvoice['Invoice']['invoice_total'];
$bedrag = $thisInvoice['Payment']['0']['amount'];
$openbedrag = $invoiceTotal - $bedrag;
$openbedrag = $settings['Setting']['currency'].number_format($openbedrag, 2, '.', ',');
注意: - 在计算时间内也不要使用number_format。使用它吃显示时间是指在最终输出中计算后。