duankang8114 2012-09-14 17:39
浏览 48

money_format - 负数

I got the following code

#   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);

If $Income - $Spending is negative (under 0), then the income is lower then the spending. Alright. I am using my locale, french (canada) and the result for a negative number is (X,XX $).

Not having a - sign make non sense for me so I want to be able to output the number with a -0.00$ and not with (0.00$).

Example my income is 75.00$ and my spending are 100.00$. I spent 25$ more then I do so the remaining money will output (25.00$) but I want -25.00$.

I did try to add ( or + but I don't understand.

Thanks

UPDATE: Picture

enter image description here

  • 写回答

1条回答 默认 最新

  • duan7772 2012-09-14 17:44
    关注

    The format strings for money_format are a bit confusing. What you want is:

    money_format('%+.2n', $Income - $Spending);
    
    评论

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大