位置: 编程技术 - 正文

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

  • 固定资产清理过程涉及的报表
  • 小规模纳税人的起征点是多少
  • 上季度忘记申报个税了
  • 融资租赁本金和租金的区别
  • 加计抵减税金分录
  • 电子税务局在哪里看财务报表
  • 划转税务的非税收入2023
  • 预交土地增值税怎么计算公式
  • 海关免税设备清单
  • 公司账户存定期 定期要做利息出纳账吗
  • 企业的管理人
  • 三证合一后还要去税务局吗
  • 办公室租金相关法规
  • 个体工商户交纳社保办法
  • 什么企业做汇算清缴报告
  • 所得税汇算清缴补税的会计处理
  • 收付实现制下预收款算收入吗
  • 企业所得税期间费用利息收支
  • 注册公司有哪些好处和坏处
  • 税务局查到发票有问题
  • 出租房产如何交土地使用税
  • 企业在项目建设前必须进行
  • 查找我的iphone怎么添加设备
  • win7鼠标点右键没反应
  • 合同印花税会计分录
  • 工会经费申报的依据
  • win 8和win 7有什么区别
  • 电脑桌面小工具软件
  • 公司作为股东有什么好处
  • 总承包合同如何约定农民工工资
  • 外币借款费用
  • 进项税额转出的所有会计分录
  • php数据库分页是怎么实现的
  • html零基础入门教程
  • gdal官方文档
  • 35.JavaScript对象和数组的解构赋值基础详解、let陷阱、函数参数解构
  • thinkphp官网
  • php导出带样式的数据库
  • 以前年度损益调整是什么意思
  • 深究Python中的asyncio库-线程同步
  • 管理费用中的福利费有限额吗
  • 提取现金准备发放工资
  • 个税申报和社保申报的金额要一致吗
  • 数据库 sql优化
  • Shading-JDBC、ShadingSphere、ShardingProxy 使用详解
  • 无票收入如何报税
  • 成品油红字发票开具后库存数量如何冲回?
  • 网上更正增值税申报表
  • 固定资产投资额是指什么
  • ubuntu20.04vim
  • 在资产减值准备中符合条件可以转回的有
  • 利润分配会计处理例题
  • 金税四期视频
  • 企业所得税季度平均值怎么算
  • 商业银行提取的盈余公积可用于
  • 研发支出如何做账
  • 个体户减免税额怎么填
  • 购买债券的交易费计入什么科目
  • 租车运货产生的费用
  • 企业主营业务收入分录
  • 金税盘可以用热点吗
  • 企业发票冲红的风险
  • sql server的基本概念
  • Centos7 下Mysql5.7.19安装教程详解
  • 通过SQL语句直接把表导出为XML格式
  • kvm虚拟机paused
  • win2003开启远程桌面
  • 红帽子一个月能挣多少钱
  • linux系统怎样安装
  • win7系统有wifi功能吗
  • Linux系统中的pycharm怎么打开
  • win7系统登录QQ失败提示QQ软件已被破坏或部分文件已经丢失的解决方法
  • Win10预览版拆弹
  • win10小娜无法启动语音识别
  • retail版win10
  • javascript.info
  • Unity3D游戏开发引擎
  • python ip地址转换
  • javascript post语法
  • 个人所得税的通知
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

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

    友情链接: 武汉网站建设