位置: 编程技术 - 正文

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字符串函数有哪些)

  • 税率变化递延所得税资产怎么计算
  • 销售服务增值税税率
  • 企业捐赠灾区
  • 商业承兑汇票贴现率
  • 所得税流程
  • 运输企业支付罚款如何账务处理
  • 已认证未抵扣的进项怎么填写
  • 可供出售金融资产是指什么
  • 佣金收入者是什么意思
  • 进口设备在海关处保存2年出售时 计算税怎么算
  • 客户回款扣除的手续费会计分录怎么做?
  • 收到一笔误缴的税款
  • 企业销售产品的成本是指已销产品的
  • 退预付账款会计分录
  • 增值税发票收款人复核人空白可以吗
  • 建筑劳务公司收到劳务费会计分录
  • 安装服务异地施工增值税在哪交
  • 没有认证的进项发票怎么入账
  • 单位定期存款支取
  • 贷款本金余额具体是什么意思
  • 员工差旅补贴是否需要发票
  • 个体工商户变更法人
  • 备用金发票冲抵
  • 什么叫递延所得税费用?
  • 主营业务利润计算
  • 会计帐务处理程序
  • 结转法定盈余公积会计分录怎么写
  • 软件开发公司账务怎么做
  • 苹果14出来13会下架吗
  • PHP:mb_regex_encoding()的用法_mbstring函数
  • 清除cmos数据按钮一直亮
  • 日记账和总账一般采用
  • 代开增值税发票沒有付款怎么做账?
  • 金融资产的会计处理方法
  • phptoken验证原理
  • 负债大于资产是逆差还是顺差
  • 关停所有swap分区的命令
  • 结转,结余
  • php面向对象的三大特征
  • pdclient
  • java异常编程题
  • 净收入是营业收入吗
  • 2020信息采集
  • 金税盘怎么取消
  • 小规模纳税人通行费电子普票能抵扣吗
  • 一般纳税人废业企业库存怎么办
  • 如果没有抄税就申报了
  • 资产类账户有哪些
  • 银行对账单由谁负责
  • sqlserver2008安装完在哪打开
  • sqlserver连接到服务器登录名
  • 一行的代码
  • 办培训机构需要什么条件手续
  • 接受非货币性资产投资入账价值
  • 生产成本有贷方余额怎么调整
  • 所得税费用的核算方法叫
  • 其他权益工具包括交易性金融资产吗
  • 股东向公司借款多久必须归还
  • 报销核销
  • 安全生产费计提和使用的账务怎么处理
  • 怎么看懂自己的收入纳税
  • 某酒店住宿费用定价分析
  • 购进中央空调可以抵税吗
  • 事业单位不允许办企业是哪个文件要求的
  • sql语句 时间差
  • win8开机错误
  • windows server 2008 R2
  • linux ifcon
  • win7系统资源管理器无响应
  • perl中的$1
  • unity2d横版游戏源码
  • opengl文档窗口是什么
  • Unity3D游戏开发标准教程
  • 用原生js写项目
  • Node.js中的什么模块是用于处理文件和目录的
  • 细说javascript
  • unity 内存管理
  • jquery教程与例子
  • 电子发票软件怎么打开
  • 企业年度申报怎么修改
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

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

    友情链接: 武汉网站建设