我得到了以下代码
# On va convertir en somme monétaire
# We convert our integer into a way to read money
$Vars['Income'] = money_format('%.2n', $Income);
$Vars['Spending'] = money_format('%.2n', $Spending);
# On va calculer ce qui reste à dépenser
# We do the math to know how much we can spend until the end of the month
$Vars['Remaining'] = money_format('%.2n', $Income - $Spending);如果$Income - $Spending为负(低于0),则收入低于支出。好的。我使用的是我的地区法语(加拿大),负数的结果是(X,XX $)。
没有-符号对我来说毫无意义,所以我希望能够输出带有-0.00$而不是(0.00$)的数字。
我的收入是75美元,我的支出是100.00美元。我花了比我多25美元,所以剩余的钱将输出(25.00美元),但我想-25.00美元。
我确实试着加了(或+,但我不明白。
谢谢
更新:Picture

发布于 2012-09-15 01:44:26
money_format的格式字符串有点混乱。你想要的是:
money_format('%+.2n', $Income - $Spending);https://stackoverflow.com/questions/12429397
复制相似问题