我得到了以下代码
# 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);
Run Code Online (Sandbox Code Playgroud)
如果$Income - $Spending是负数(低于0),则收入低于支出.好的.我正在使用我的语言环境,法语(加拿大),负数的结果是(X,XX $).
没有 - 符号对我来说没有意义所以我希望能够输出-0.00 $而不是(0.00 $)的数字.
示例我的收入是75.00 $,我的支出是100.00 $.我花了25美元,然后我这样做剩余的钱将输出(25.00美元),但我想-25.00 $.
我确实尝试添加(或+但我不明白.
谢谢
更新:图片

格式字符串money_format有点令人困惑.你想要的是:
money_format('%+.2n', $Income - $Spending);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1964 次 |
| 最近记录: |