dptdb84606 2013-10-29 11:18 采纳率: 0%
浏览 42
已采纳

如何在数组PHP中将数字格式化为货币?

Im having trouble with this code - getting a 500 error, I need to format as currency for the values in an array. But getting stuck:

If I use round() - it will work - but it just rounds the number, which is not what Im after.

$cart[] = array('name' => $message->name, 'values' => array(round($delivery->revenue), $delivery->uniqConversions));

But if I try to use money_format, it does not work:

$cart[] = array('name' => $message->name, 'values' => array(money_format('$%i', ($delivery->revenue), $delivery->uniqConversions));

Any Ideas?

  • 写回答

1条回答 默认 最新

  • douding_1073 2013-10-29 11:21
    关注

    Its because you are missing ) at the end of your line:

    $cart[] = array('name' => $message->name, 'values' => array(money_format('$%i', ($delivery->revenue), $delivery->uniqConversions)));
    

    Thats why you are getting Error 500.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥60 ESP32怎么烧录自启动程序
  • ¥50 html2canvas超出滚动条不显示
  • ¥15 MATLAB四叉树处理长方形tif文件
  • ¥15 java业务性能问题求解(sql,业务设计相关)
  • ¥15 52810 尾椎c三个a 写蓝牙地址
  • ¥15 elmos524.33 eeprom的读写问题
  • ¥15 使用Java milo连接Kepserver服务端报错?
  • ¥15 用ADS设计一款的射频功率放大器
  • ¥15 怎么求交点连线的理论解?
  • ¥20 软件开发方法学习来了