位置: 编程技术 - 正文

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

  • 资金账簿印花税和营业账簿的区别
  • 主管盾和制单盾的区别
  • 车辆购置税能否退税
  • 增值税抵扣不够怎么解决
  • 车船税在备注栏怎么报表
  • 企业资产折旧抵扣所得税
  • 有限责任公司(自然人投资或控股)
  • 发票未到货已到怎么入账
  • 企业所得税研发费用100%扣除的有哪些企业
  • 物业收停车费要交房产税吗
  • 应交税费算什么费用
  • 增值税一般纳税企业支付现金方式取得
  • 归还银行贷款利息分录
  • 企业出售已使用过的固定资产税率
  • 国有资产拍买网
  • 交纳经营所得的个税怎么做分录?
  • 医院职工福利费使用范围和标准是多少
  • 个人所得税成本费用怎么算
  • 城市维护建设税属于什么税种
  • 网上申报城建税及附加怎么操作
  • 地价计入房产
  • win10j截图
  • 培训费发票模板
  • 收入3000以下占比
  • 其他应付款长期挂账税务处理
  • 抵押,质押,留置的区别与联系
  • 投资新公司的账务处理
  • 开始菜单中的磁贴是什么
  • 虎刺梅怎么养殖视频
  • PHP:imagerectangle()的用法_GD库图像处理函数
  • 利用php判断是否为素数
  • php递归函数的例子
  • 代订住宿费报销
  • 应付账款借方怎么重分类
  • arc架构
  • 农产品加计扣除1%怎么计算和会计分录
  • date=date
  • 不动产固定资产的进项税抵扣新规定
  • 润滑脂开票属于哪一类
  • 怎么把其他应收款借方余额转出
  • 新准则委托代建会计处理
  • 异地预缴税款多交了有影响吗
  • sql-server
  • 一般计税方法预交增值税
  • 单位买理财产品怎么买
  • 小规模纳税人批发零售税率
  • 小规模纳税人适用5%的税率是什么
  • 坏账准备是啥意思
  • 流动资产属于经营资产还是得经营资产
  • 我国的税种及税率
  • 投资购入房产会亏钱吗
  • 微信收款如何做账报税
  • 展厅租赁税率
  • 差旅费账务处理的摘要
  • 需要计提坏账准备吗
  • 未抵扣进项税额转出会计分录
  • 最新职工福利费列支范围
  • 会计凭证发票粘贴
  • mysql的事务处理
  • 服务器系统2003
  • Windows Server 2003关闭启动后的Ctrl+Alt+Del选项和关机时的时间跟踪程序方法
  • uca1
  • 从五方面解析Linux防火墙框架问题
  • 使用灭火器人要站在上风口还是下风口
  • nodejs怎么启动服务
  • nodejs bff
  • python快速排序算法代码
  • javascript小数四舍五入多种方法实现
  • shell脚本自动执行
  • javascript 组件
  • jquery 异步请求
  • 双色球兑奖方式选法
  • 辽宁新农合怎么停保
  • 诺诺开票软件怎么领用发票
  • 新疆喀什泽普县海拔高度是多少米
  • 湖北省地税局稽查局
  • 甘肃省国家税务局电子税务局
  • 企业税收怎么收
  • 地税怎么交税
  • 营业税纳税申报时间
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

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

    友情链接: 武汉网站建设