mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
Unfinished initial documentation
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@109292 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
23b5980411
commit
c14b7cfaf1
1 changed files with 181 additions and 0 deletions
181
reference/strings/functions/money-format.xml
Normal file
181
reference/strings/functions/money-format.xml
Normal file
|
@ -0,0 +1,181 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.1 $ -->
|
||||
<refentry id="function.money-format">
|
||||
<refnamediv>
|
||||
<refname>money_format</refname>
|
||||
<refpurpose>Formats a number as a currency string</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1>
|
||||
<title>Description</title>
|
||||
<methodsynopsis>
|
||||
<type>string</type><methodname>money_format</methodname>
|
||||
<methodparam><type>string</type><parameter>format</parameter></methodparam>
|
||||
<methodparam><type>float</type><parameter>number</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
<function>money_format</function> returns a formatted version of
|
||||
<parameter>number</parameter>. This function wraps the C library
|
||||
function <function>strfmon</function>, with the difference that
|
||||
this implementation converts only one number at a time.
|
||||
</para>
|
||||
<para>
|
||||
The format specification consists of the following sequence:
|
||||
<itemizedlist>
|
||||
<listitem><para>a <literal>%</literal> character</para></listitem>
|
||||
<listitem><para>optional flags</para></listitem>
|
||||
<listitem><para>optional field width</para></listitem>
|
||||
<listitem><para>optional left precision</para></listitem>
|
||||
<listitem><para>optional right precision</para></listitem>
|
||||
<listitem><para>a required conversion character</para></listitem>
|
||||
</itemizedlist>
|
||||
</para>
|
||||
<formalpara>
|
||||
<title>Flags</title>
|
||||
<para>
|
||||
One or more of the optional flags below can be used:
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><literal>=</literal><replaceable>f</replaceable></term>
|
||||
<listitem>
|
||||
<para>
|
||||
The character <literal>=</literal> followed by a a (single byte)
|
||||
character <replaceable>f</replaceable> to be used as the numeric fill
|
||||
character. The default fill character is space.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><literal>^</literal></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Disable the use of grouping characters (as defined
|
||||
by the current locale).
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><literal>+</literal> or <literal>(</literal></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Specify the formatting style for positive and negative numbers.
|
||||
If <literal>+</literal> is used, the locale's equivalent for
|
||||
<literal>+</literal> and <literal>-</literal> will be used. If
|
||||
<literal>(</literal> is used, negative amounts are enclosed in
|
||||
parenthesis. If no specification is given, the default is
|
||||
<literal>+</literal>.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><literal>!</literal></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Suppress the currency symbol from the output string.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><literal>-</literal></term>
|
||||
<listitem>
|
||||
<para>
|
||||
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).
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</para>
|
||||
</formalpara>
|
||||
<formalpara>
|
||||
<title>Field width</title>
|
||||
<para>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><replaceable>w</replaceable></term>
|
||||
<listitem>
|
||||
<para>
|
||||
A decimal digit string specifying a minimum field width. Field will
|
||||
be right-justified unless the flag <literal>-</literal> is used.
|
||||
Default value is 0 (zero).
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</para>
|
||||
</formalpara>
|
||||
<formalpara>
|
||||
<title>Left precision</title>
|
||||
<para>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><literal>#</literal><replaceable>n</replaceable></term>
|
||||
<listitem>
|
||||
<para>
|
||||
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</para>
|
||||
</formalpara>
|
||||
<para>
|
||||
<example>
|
||||
<title><function>number_format</function> Example</title>
|
||||
<para>
|
||||
For instance, French notation usually use two decimals,
|
||||
comma (',') as decimal separator, and space (' ') as
|
||||
thousand separator. This is achieved with this line :
|
||||
</para>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
$number = 1234.56;
|
||||
|
||||
// english notation (default)
|
||||
$english_format_number = number_format($number);
|
||||
// 1,234
|
||||
|
||||
// French notation
|
||||
$nombre_format_francais = number_format($number, 2, ',', ' ');
|
||||
// 1 234,56
|
||||
|
||||
$number = 1234.5678;
|
||||
|
||||
// english notation without thousands seperator
|
||||
$english_format_number = number_format($number, 2, '.', '');
|
||||
// 1234.57
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
<para>
|
||||
See also: <function>number_format</function>,<function>sprintf</function>,
|
||||
<function>printf</function> and <function>sscanf</function>.
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
mode: sgml
|
||||
sgml-omittag:t
|
||||
sgml-shorttag:t
|
||||
sgml-minimize-attributes:nil
|
||||
sgml-always-quote-attributes:t
|
||||
sgml-indent-step:1
|
||||
sgml-indent-data:t
|
||||
indent-tabs-mode:nil
|
||||
sgml-parent-document:nil
|
||||
sgml-default-dtd-file:"../../../../manual.ced"
|
||||
sgml-exposed-tags:nil
|
||||
sgml-local-catalogs:nil
|
||||
sgml-local-ecat-files:nil
|
||||
End:
|
||||
vim600: syn=xml fen fdm=syntax fdl=2 si
|
||||
vim: et tw=78 syn=sgml
|
||||
vi: ts=1 sw=1
|
||||
-->
|
Loading…
Reference in a new issue