位置: 编程技术 - 正文

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

  • 行政法律法规是规定行政机关
  • 公司汽车的折旧费可以扺税吗
  • 销售使用过的固定资产如何开票
  • 非财政拨款结余是什么科目
  • 营改增账务处理实例
  • 公司开给个人的发票有什么用
  • 增值税发票的基数是什么
  • 加盟费怎么算的
  • 新股东入股怎么写记账凭证摘要
  • 企业注销后款项怎么结算
  • 3月申报的是什么时候的个税
  • 支付印花税计入什么科目
  • 异地预缴本地申报流程
  • 电子产品企业用电量大吗
  • 资产置换会计处理办法
  • 小规模纳税人如何计算增值税
  • 预付款能开发票吗?
  • 增值税专用发票查询系统官方网站
  • php检测文件是否存在
  • windows为什么从7开始
  • 辅助生产成本如何结转
  • 住房公积金会扣税吗
  • 新准则规定
  • 苹果手机热点打不开是灰色的
  • nodejs怎么降低版本
  • 亨茨维尔机场
  • 增量预算对应什么预算
  • 扣缴单位无有效的税费种认定信息
  • thinkPHP5 tablib标签库自定义方法详解
  • 发票已开,款未到的会计分录
  • 不得抵扣的增值税怎么处理
  • pytorch训练模型计算f1
  • Vue3通透教程【一】Vue3现状—必然趋势?
  • vue实现登陆
  • man-s命令
  • 单据已经生成凭证,不允许自动删除
  • 企业年度汇算清缴申报表填写
  • 体检费专票可以抵扣吗
  • 农产品收购发票可以抵扣进项税额吗
  • 公司一般户财务负责人是另一公司法人
  • 应收账款项目的金额公式
  • 帝国cms灵动标签排除上一篇下一篇文章
  • 国家税务总局关于营改增后土地增值税
  • python中的函数库
  • mysql更新视图的方式
  • mysql查询性能优化
  • 钢筋增值税专票几个点
  • 小规模免税怎么做账务处理
  • 会计电算化的内容和任务
  • 差旅费报销范围包括
  • 固定资产折旧指标有哪些
  • 商标注册费2000元记哪个科目
  • 会计凭证保管期限30年是哪一年开始的
  • 付款后没有发票怎么办
  • 客户罚款员工承担
  • 结转本月销售材料成本
  • 关联企业有什么好处
  • mysql远程用户登录
  • 彻底删除sql server2019
  • SQL Server"错误 21002: [SQL-DMO]用户 * 已经存在问题解决
  • mysql迁移方案
  • 储存扩展容量
  • 增强型图形文件
  • 无法进入睡眠状态
  • xp怎么关闭自启动
  • mac购买建议
  • autorun.dll
  • windowxp系统怎么设置开机密码
  • WIN764位系统8G内存识别一半解决办法
  • win7系统运行在哪
  • hyper v安装系统
  • win7如何设置关机快捷方式
  • win8怎么把网速调到最快
  • cocos2dx 3.17
  • angular ngshow
  • node解决跨域
  • email js
  • ready jquery
  • 办公电话怎么设置铃声
  • 船舶吨税案例分析
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

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

    友情链接: 武汉网站建设