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

使用小数PHP格式化int

I'm have this number

55550

But I it should be 555.50, I tried number_format() and sprinft but did not work.

Any idea? Thanks!

<?php

$num = 55550;
$num = (float) $num / 100;

echo number_format($num, 2, ".", "");

by casting the number to float, and dividing by 100 you can use number_format to change the format.

近期文章

  • PHP表单与jQuery DatePicker
  • PHP动态字段INSERT MySQL
  • 在表单中发送POST和GET
  • PHP:将数组输出到表中
  • yii2用图像多重选择
  • 可以php(wapache)运行远程文件吗?
  • 使用php htaccess重写URL?
  • 在ajax中显示数据库中的数据
  • 顺序#id传递给jQuery
  • Laravel hasManyThrough 2表
  • 我的PHP代码给出了错误,为什么? [关闭]
  • 在ajax之后覆盖页面缓存
  • PHP正则表达式缺少捕获组
  • 很多很多人都会得到价值
  • PHP在foreach循环中设置值
  • 在php的倒数第二个月
  • 选择的子查询选择
  • 根据键值删除数组
  • 在函数中调用自定义PHP
  • too long

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

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

友情链接:代码精华