zoukankan      html  css  js  c++  java
  • number_format

    number_format — 以千位分隔符方式格式化一个数字

    说明

    string number_format ( float $number [, int $decimals = 0 ] )
    string number_format ( float $number , int $decimals = 0 , string $dec_point = "." , string $thousands_sep = "," )

    本函数可以接受1个、2个或者4个参数(注意:不能是3个):

    如果只提供第一个参数,number的小数部分会被去掉 并且每个千位分隔符都是英文小写逗号","

    如果提供两个参数,number将保留小数点后的位数到你设定的值,其余同楼上

    如果提供了四个参数,number 将保留decimals个长度的小数部分, 小数点被替换为dec_point,千位分隔符替换为thousands_sep

    参数

     

    number

    你要格式化的数字

    decimals

    要保留的小数位数

    dec_point

    指定小数点显示的字符

    thousands_sep

    指定千位分隔符显示的字符

    返回值

    格式化以后的 number.

     

     

    <?php
    
    $number = 1234.56;
    
    // english notation (default)
    $english_format_number = number_format($number);
    // 1,235
    
    // French notation
    $nombre_format_francais = number_format($number, 2, ',', ' ');
    // 1 234,56
    
    $number = 1234.5678;
    
    // english notation without thousands separator
    $english_format_number = number_format($number, 2, '.', '');
    // 1234.57
    
    ?>
    

      

  • 相关阅读:
    osg控制相机移动
    osg绘制胶囊体
    Pset_RampFlightCommon
    osg抓图
    osg截取场景图片
    osg实现三视图
    Sonar系列:Gitlab集成Sonarqube实现自动检测代码并发送报告给提交者(五)
    Sonar系列:通过Jenkins集成sonarqube做持续扫描(四)
    来到这座城市3年了
    DongTai--被动型IAST工具部署体验
  • 原文地址:https://www.cnblogs.com/yangcclg/p/5053058.html
Copyright © 2011-2022 走看看