位置: 编程技术 - 正文

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

  • 如何确定开票税率是否正确
  • 单位历史遗留问题
  • 小微企业季度平均资产看每季度吗
  • 产品成本计算的基本方法和辅助方法的划分标准是
  • 发票验旧日期是什么意思
  • 成品油认证后要开票怎么做
  • 金蝶多核算项目怎么做
  • 累计折旧和固定资产减值准备的区别
  • 小企业会计准则会计科目表
  • 非正常损失会计利润调整
  • 房地产形象海报
  • 修理费没有发票怎么做账
  • 增值税发票可以抵税吗
  • 零退税率可以做免税吗
  • 合伙企业出资额不计入实收资本和资本公积 那放哪
  • 进项票异常如何自查
  • 宽带合同属于什么合同
  • 企业所得税应纳税所得额包括什么
  • 土地出让金缴纳契税计税依据
  • 商场现金收入如何计算
  • 小规模企业低值易耗品摊销方法
  • 去年多确认收入今年怎么调整
  • 备抵法发生坏账分录
  • 营改增后兼营非应税劳务的税务处理怎么做?
  • 租用办公室协议书
  • 个税汇算清缴包含退休金吗
  • 红字专用发票信息表
  • 企业所得税汇算清缴操作流程
  • linux 隐藏权限
  • php字符串函数大全
  • 补缴的土地出让金契税
  • 接受赠品的账务处理流程
  • 已缴增值税的账务处理
  • php内核剖析
  • 关于政府的话
  • 核定征收的企业注销需要缴纳个人所得税吗
  • 房地产开发企业增值税怎么算
  • 企业收到发票冲销怎么办
  • 个税专项附加扣除具体怎么操作
  • 回扣,折扣和佣金都具有违法性对吗
  • 企业应付账款明细表
  • mongodb安装包下载
  • 钢筋增值税专票几个点
  • 运费和什么有关
  • 网上纳税申报有时间限制吗
  • 比较详细的耐克知识大全
  • 一般计税预缴增值税2%怎么算
  • 存货报废应如何进行账务处理
  • 无形资产专利技术属于
  • 固定资产盘亏账务处理的问题
  • 非税收入一般缴款书是什么意思
  • 应收账款对应什么会计科目
  • 成本法核算的投资收益缴纳企业所得税
  • 企业买期货账务处理
  • 退货开负数发票的情况该如何做会计处理?
  • 进出口企业需要哪些手续
  • 企业享受所得税免税政策
  • sqlserver数据库事物日志已满
  • mysql中排序规则是什么意思
  • MySQL 5.7.14 net start mysql 服务无法启动-“NET HELPMSG 3534” 的奇怪问题
  • 笔记本没有光驱怎么加装固态硬盘
  • centos命令行乱码
  • centos如何配置ip
  • winio在win7下使用
  • 怎么看win7
  • linux中密码信息存在哪个文件
  • window批处理
  • bat 截取字符串
  • 怎么在html中调用js的函数
  • eventlistener js
  • 批处理 leq
  • Android性能优化的方面12个
  • [置顶]游戏名:chivalry2
  • unity3d ik
  • jQuery插件AjaxFileUpload实现ajax文件上传
  • 土地招标拍卖挂牌
  • 完税凭证验证码
  • 伊川娘娘山传说
  • 青岛税务局局长是什么级别?
  • 广西南宁地税局电话
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

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

    友情链接: 武汉网站建设