我爱占星网 我爱占星网
首页
编程
java
php
前端
首页 编程 java php 前端

在echo中删除最后3个字符

i have a php function here echo $balance['credit'];

which outputs numbers like this 34.60000

I dont want it to have the 3 extra 0's so how do i strip the last 3 ?

I tried using this here but didnt work. strip characters

Use printf to do formatted printing. E.g., echo sprintf('%.2f', $balance['credit']);

Try

echo number_format($balance['credit'], 2, '.', '')

See demo

近期文章

  • SQL查找相关文本框
  • 从PHP调用MATLAB可执行文件
  • Mysql DB无法正确更新
  • 表单提交后重定向用户
  • 用php准备CURL请求
  • PHP中的语法或变量错误
  • 通过PHP脚本Wansview CGI 401
  • 如何在yii2中隐藏php警告?
  • 转换/显示日期的最佳方式
  • PHP数组,然后检查是否在数据中
  • 将URL转换为屏幕截图(脚本)
  • Php #home页面没有重定向
  • PHP PDO尝试。 处理重复
  • 如何保存用户制作的HTML页面?
  • Laravel在php中保存选项文本
  • php curl重置或修改cookie
  • CodeIgniter控制器和AJAX
  • 从提交ID进行ajax调用
  • 这是什么表达方式? [重复]
  • 将接下来的30天放入阵列

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

部分图文来自网络,如有侵犯您的版权,请告诉我们删除

友情链接:代码精华