位置: 编程技术 - 正文

PHP字符串函数money_format()的用法(php字符串函数有哪些)

编辑:rootadmin
money_format

推荐整理分享PHP字符串函数money_format()的用法(php字符串函数有哪些),希望有所帮助,仅作参考,欢迎阅读内容。

文章相关热门搜索词:php字符串型数据的定义方式,php字符串定义的三种方式,php 字符串函数,php字符串定义的三种方式,php 字符串函数,php 字符串函数,php字符串定义的三种方式,php字符串型数据的定义方式,内容如对您有帮助,希望把文章链接给更多的朋友!

(PHP 4 >= 4.3.0, PHP 5)

money_format — Formats a number as a currency string

说明 string money_format ( string $format , float $number )

money_format() returns a formatted version of number. This function wraps the C library function strfmon(), with the difference that this implementation converts only one number at a time.

参数

format

The format specification consists of the following sequence:

a % character

optional flags

optional field width

optional left precision

optional right precision

a required conversion character

Flags

One or more of the optional flags below can be used:=f

The character = followed by a (single byte) character f to be used as the numeric fill character. The default fill character is space.

^

Disable the use of grouping characters (as defined by the current locale).

+ or (

Specify the formatting style for positive and negative numbers. If + is used, the locale&#;s equivalent for + and - will be used. If ( is used, negative amounts are enclosed in parenthesis. If no specification is given, the default is +.

!

Suppress the currency symbol from the output string.

-

If present, it will make all fields left-justified (padded to the right), as opposed to the default which is for the fields to be right-justified (padded to the left).

Field width

w

A decimal digit string specifying a minimum field width. Field will be right-justified unless the flag - is used. Default value is 0 (zero).

PHP字符串函数money_format()的用法(php字符串函数有哪些)

Left precision

#n

The maximum number of digits (n) expected to the left of the decimal character (e.g. the decimal point). It is used usually to keep formatted output aligned in the same columns, using the fill character if the number of digits is less than n. If the number of actual digits is bigger than n, then this specification is ignored.

If grouping has not been suppressed using the ^ flag, grouping separators will be inserted before the fill characters (if any) are added. Grouping separators will not be applied to fill characters, even if the fill character is a digit.

To ensure alignment, any characters appearing before or after the number in the formatted output such as currency or sign symbols are padded as necessary with space characters to make their positive and negative formats an equal length.

Right precision

.p

A period followed by the number of digits (p) after the decimal character. If the value of p is 0 (zero), the decimal character and the digits to its right will be omitted. If no right precision is included, the default will dictated by the current local in use. The amount being formatted is rounded to the specified number of digits prior to formatting.

Conversion characters

i

The number is formatted according to the locale&#;s international currency format (e.g. for the USA locale: USD 1,.).

n

The number is formatted according to the locale&#;s national currency format (e.g. for the de_DE locale: EU1.,).

%

Returns the % character.

number

The number to be formatted.

返回值

Returns the formatted string. Characters before and after the formatting string will be returned unchanged. Non-numeric number causes returning NULL and emitting E_WARNING.

注释

Note:

The function money_format() is only defined if the system has strfmon capabilities. For example, Windows does not, so money_format() is undefined in Windows.

Note:

The LC_MONETARY category of the locale settings, affects the behavior of this function. Use setlocale() to set to the appropriate default locale before using this function.

范例

Example #1 money_format() Example

We will use different locales and format specifications to illustrate the use of this function.

<?php$number=.;//let'sprinttheinternationalformatfortheen_USlocalesetlocale(LC_MONETARY,'en_US');echomoney_format('%i',$number)."n";//USD1,.//Italiannationalformatwith2decimals`setlocale(LC_MONETARY,'it_IT');echomoney_format('%.2n',$number)."n";//Eu1.,//Usinganegativenumber$number=-.;//USnationalformat,using()fornegativenumbers//anddigitsforleftprecisionsetlocale(LC_MONETARY,'en_US');echomoney_format('%(#n',$number)."n";//($1,.)//Similarformatasabove,addingtheuseof2digitsofright//precisionand'*'asafillcharacterechomoney_format('%=*(#.2n',$number)."n";//($********1,.)//Let'sjustifytotheleft,withpositionsofwidth,8digitsof//leftprecision,2ofrightprecision,withouthgroupingcharacter//andusingtheinternationalformatforthede_DElocale.setlocale(LC_MONETARY,'de_DE');echomoney_format('%=*^-#8.2i',.)."n";//Eu,****//Let'saddsomeblurbbeforeandaftertheconversionspecificationsetlocale(LC_MONETARY,'en_GB');$fmt='Thefinalvalueis%i(aftera%%discount)';echomoney_format($fmt,.)."n";//ThefinalvalueisGBP1,.(aftera%discount)?>

参见

setlocale() - Set locale information sscanf() - 根据指定格式解析输入的字符 sprintf() - Return a formatted string printf() - 输出格式化字符串 number_format() - 以千位分隔符方式格式化一个数字

PHP字符串函数nl2br()的用法 nl2br(PHP4,PHP5)nl2br在字符串所有新行之前插入HTML换行标记说明stringnl2br(string$string[,bool$is_xhtml=true])在字符串string所有新行之前插入br/或br,并返回。参数str

PHP字符串函数nl_langinfo()的用法 nl_langinfo(PHP4=4.1.0,PHP5)nl_langinfoQuerylanguageandlocaleinformation说明stringnl_langinfo(int$item)nl_langinfo()isusedtoaccessindividualelementsofthelocalecategories.Unlikelocaleconv(),whichretu

PHP字符串函数metaphone()的用法 metaphone(PHP4,PHP5)metaphoneCalculatethemetaphonekeyofastring说明stringmetaphone(string$str[,int$phonemes=0])Calculatesthemetaphonekeyofstr.Similartosoundex()metaphonecreatesthesamekeyforsimilarsou

标签: php字符串函数有哪些

本文链接地址:https://www.jiuchutong.com/biancheng/278852.html 转载请保留说明!

上一篇:PHP字符串函数ord()的用法(php字符串函数大全)

下一篇:PHP字符串函数nl2br()的用法(php字符串函数有哪些)

  • 保本理财增值税可以开票吗怎么开
  • 固定资产清理过程涉及的报表
  • 商品流通企业应收账款的研究
  • 专利权的手续费是多少
  • 附加税费申报没有怎么填
  • 没有购置税发票有影响吗
  • 境外增值税代扣代缴
  • 产品税率下调企业是否要到税务部门备案
  • 公司股东变更麻烦吗?
  • 个体户核定征收超过了怎么办
  • 劳务报酬个人所得税怎么计算
  • 增值税怎么补提
  • 关于非上市公司的法律
  • 工程结算在资产负债表的哪个科目
  • 发票认证后还要做什么
  • 票据结算包括哪几项
  • windows10如何开机启动软件
  • 坏账计提方法和比例
  • compaq-rba.exe是哪个方面的进程 作用是什么 compaq-rba进程查询
  • 销售农产品的进项税
  • 以下哪些企业需要填报
  • 委托加工物资加工费计入
  • php和ajax用哪个调用数据
  • 实际成本法核算会计分录
  • php网页安全认证是什么
  • laravel技巧
  • vue-router
  • vue3使用ref获取元素
  • ConvNeXt V2学习笔记
  • 原生js获取document
  • ssh -o命令
  • 出口退税率和进项税额
  • 印花税账务处理会计分录
  • 无法支付其他应用怎么办
  • 现金流量表的填列方法
  • 文化事业建设费税收优惠2023
  • 帝国cms灵动标签怎么调用
  • 固定什么意思
  • 委托加工应税消费品是指委托方提供原料和主要材料
  • 收到发票未收到货物
  • 营改增后服务业账务处理
  • 退休人员返聘签订什么合同
  • 电子商务会计科目有哪些
  • 工会活动支出如何记账
  • 收银员长款短款什么意思
  • 账户分类的作用是什么
  • 知识产权代理所代理
  • 查看sqlserver操作记录
  • 安装mysql5.7虚拟机教程
  • mysql 行转列 列转行
  • 修改文件软件免费下载
  • windows service 2008 r2
  • WUSB54GS.exe - WUSB54GS是什么进程
  • 怎么快速
  • win7开机提示便签损坏
  • mac屏幕共享软件
  • win10启动很慢怎么办
  • os x10.8.5
  • vim的配置文件名
  • shwiconem.exe - shwiconem是什么进程 有什么用
  • apache for mac
  • 使用JQuery实现Ctrl+Enter提交表单的方法
  • jQuery+AJAX实现遮罩层登录验证界面(附源码)
  • dos命令批处理文件
  • javascript如何输出变量
  • javascript entries
  • jquery实现图片横向移动
  • unity api compatibility level
  • javascript闭包的作用
  • 怎么设置python前面序号
  • android 布局属性大全
  • javascript模块化与非模块化开发区别
  • android studio 运行配置
  • 每年个人所得税2万工资多少
  • 车库契税怎么收费
  • 个人开服务费发票 个人所得税
  • 山西省税务局政审县级还是市级的
  • 设计费需要交税吗
  • 个体户定额纳税
  • 应纳税所得额怎么求公式
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

    网站地图: 企业信息 工商信息 财税知识 网络常识 编程技术

    友情链接: 武汉网站建设