mirror of
https://github.com/macintoshplus/doc-fr.git
synced 2026-04-28 11:13:14 +02:00
4a239ae2da
git-svn-id: https://svn.php.net/repository/phpdoc/fr/trunk@172818 c90b9560-bf6c-de11-be94-00142212c4b1
103 lines
3.4 KiB
XML
103 lines
3.4 KiB
XML
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
<!-- $Revision: 1.12 $ -->
|
|
<!-- EN-Revision: 1.6 Maintainer: didou Status: ready -->
|
|
<refentry id="function.number-format">
|
|
<refnamediv>
|
|
<refname>number_format</refname>
|
|
<refpurpose>Formate un nombre pour l'affichage</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type>string</type><methodname>number_format</methodname>
|
|
<methodparam><type>float</type><parameter>number</parameter></methodparam>
|
|
<methodparam choice="opt"><type>int</type><parameter>decimals</parameter></methodparam>
|
|
<methodparam choice="opt"><type>string</type><parameter>dec_point</parameter></methodparam>
|
|
<methodparam><type>string</type><parameter>thousands_sep</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
<function>number_format</function> retourne une chaîne représentant
|
|
<parameter>number</parameter> formaté. <function>number_format</function>
|
|
accepte un, deux ou 4 paramètres (mais pas trois).
|
|
</para>
|
|
<para>
|
|
Si seul le paramètre <parameter>number</parameter> est donné,
|
|
il sera formaté sans partie décimale, mais avec une
|
|
virgule entre chaque millier.
|
|
</para>
|
|
<para>
|
|
Si les deux paramètres <parameter>number</parameter> et
|
|
<parameter>decimals</parameter> sont fournis, <parameter>number</parameter> sera
|
|
formaté avec <parameter>decimals</parameter> décimales,
|
|
un point (".") comme séparateur décimal et une virgule entre chaque
|
|
millier.
|
|
</para>
|
|
<para>
|
|
Avec quatre paramètres, <parameter>number</parameter> sera
|
|
formaté avec <parameter>decimals</parameter> décimales,
|
|
<parameter>dec_point</parameter> comme séparateur décimal, et
|
|
<parameter>thousands_sep</parameter> comme séparateur de milliers.
|
|
</para>
|
|
<para>
|
|
Seul le premier caractère du paramètre <parameter>thousands_sep</parameter>
|
|
est utilisé. Par exemple, si vous utilisez <literal>foo</literal> comme
|
|
séparateur de milliers, sur le nombre <literal>1000</literal>,
|
|
<function>number_format</function> retournera <literal>1f000</literal>.
|
|
</para>
|
|
<para>
|
|
En notation française, on utilise généralement deux chiffres
|
|
après la virgule, une virgule comme séparateur décimal, et un
|
|
espace comme séparateur de milliers. Cela donne :
|
|
<example>
|
|
<title>Exemple avec <function>number_format</function></title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
|
|
$nombre = 1234.56;
|
|
// Notation anglaise (par défaut)
|
|
$english_format_number = number_format($nombre); // 1,234.56
|
|
|
|
// Notation française
|
|
$nombre_format_francais = number_format($nombre, 2, ',', ' ');
|
|
// 1 234,56
|
|
|
|
// Notation anglaise sans séparateurs des centaines
|
|
$english_format_number = number_format($number, 2, '.', '');
|
|
// 1234.57
|
|
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
<para>
|
|
Voir aussi
|
|
<function>sprintf</function>,
|
|
<function>printf</function> et
|
|
<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
|
|
-->
|