位置: 编程技术 - 正文

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
  • 贷款资金取现就无法追查了吗
  • 长期待摊会计分录
  • 固定资产改造时的账面价值
  • 委托代销商品的特点及种类
  • 公司购买股票的流程
  • 会计分录的表现形式有
  • 跨站脚本攻击是什么
  • 生产企业出口退税全部流程
  • 公司给员工的购房补贴
  • 个体户查账征收2023新政策是什么
  • 微信小程序开发平台
  • 增值税专用发票的税率是多少啊
  • 托收的收款人是谁
  • 营改增后工程分包财务
  • 织梦标签教程
  • 其他收入工会经费是什么意思
  • 结转以后年度扣除的费用有哪些
  • 酒店如何控制成本汇报怎么写
  • SQL Server Management Studio教程
  • 对公外汇汇款业务
  • 处理交易性金融资产增值税买价含佣金吗
  • 代垫电费收回开票吗
  • 变动成本法的计算步骤
  • 新冠捐款捐物新闻
  • 理财到期的会计怎么做账
  • 报关单是美元收欧元
  • 报废厂子出售
  • 固定资产原价的含义
  • 个人如何成立公司
  • 建账前应该考虑哪些问题
  • 会计账簿的更换和保管有哪些要求
  • MySQL存储过程和函数有什么区别?
  • centos5.7
  • 其他操作系统类型
  • 盗版win10系统
  • window系统怎么更新版本
  • 进程死锁原因
  • WINDOWS系统中删除放入回收站的文件占用什么空间
  • win7无法登录qq
  • win7开始图标怎么变大点
  • win10桌面底部
  • win 8怎么样
  • win7进入dos的方法
  • win7系统连不了网络
  • unity3d官方
  • jquery源码是什么水平
  • javascript中的关键字有哪些
  • unity安卓手机游戏官网
  • js indexof 对象
  • python的爬虫模块
  • python基础视频教程
  • js窗口关闭触发事件
  • art+project
  • android 标签栏
  • 工会的会费收入是什么意思
  • 旅游景区可免交土地使用税
  • 四川税务干部学校官网
  • sp海淘3档到国内什么快递
  • 北京第六税务所电话号码
  • 办理企业步骤
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

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

    友情链接: 武汉网站建设