mirror of
https://github.com/php/doc-it.git
synced 2026-03-26 00:22:14 +01:00
git-svn-id: https://svn.php.net/repository/phpdoc/it/trunk@314558 c90b9560-bf6c-de11-be94-00142212c4b1
107 lines
3.7 KiB
XML
107 lines
3.7 KiB
XML
<?xml version="1.0" encoding="UTF-8"?>
|
|
<!-- EN-Revision: n/a Maintainer: darvina Status: ready -->
|
|
<!-- splitted from ./en/functions/math.xml, last change in rev 1.2 -->
|
|
<refentry xml:id="function.number-format" xmlns="http://docbook.org/ns/docbook">
|
|
<refnamediv>
|
|
<refname>number_format</refname>
|
|
<refpurpose>Formatta un numero con i gruppi delle migliaia</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Descrizione</title>
|
|
<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>
|
|
La funzione <function>number_format</function> restituisce una versione formattata
|
|
di <parameter>number</parameter>. Questa funzione accetta uno,
|
|
due, o quattro parametri (non tre).
|
|
</para>
|
|
<para>Se si specifica soltanto un parametro, il
|
|
<parameter>number</parameter> sarà formattato senza decimali,
|
|
ma con la virgola (",") per suddividere le migliaia.
|
|
</para>
|
|
<para>
|
|
Se sono specdificati due parametri, il <parameter>number</parameter> sarà
|
|
formattato con tante cifre decimali quanto indicato in <parameter>decimals</parameter>,
|
|
precedute dal punto ("."), e con la virgola (",") come separatore delle
|
|
migliaia.
|
|
</para>
|
|
<para>
|
|
Se sono indicati tutti i quattro parametri, il <parameter>number</parameter>
|
|
sarà formattato con <parameter>decimals</parameter> cifre decimali,
|
|
identificate dal carattere <parameter>dec_point</parameter> anziché dal punto (".")
|
|
e con <parameter>thousands_sep</parameter>, invece della virgola (",")
|
|
come separatore delle migliaia.
|
|
</para>
|
|
<para>
|
|
Sarà utilizzato solo il primo carattere di <parameter>thousands_sep</parameter>.
|
|
Ad esempio, se si indica <literal>foo</literal> come
|
|
<parameter>thousands_sep</parameter> per il numero
|
|
<literal>1000</literal>, la funzione <function>number_format</function> restituirà
|
|
<literal>1f000</literal>.
|
|
</para>
|
|
<para>
|
|
<example>
|
|
<title>Esempio di uso di <function>number_format</function></title>
|
|
<para>
|
|
Ad esempio, la notazione francese solitamente utilizza due decimali,
|
|
la virgola (',') come separatore decimale, e lo spazio (' ')
|
|
come separatore delle migliaia. Questo può essere ottenuto con:
|
|
</para>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
|
|
$number = 1234.56;
|
|
|
|
// Notazione inglese (default)
|
|
$english_format_number = number_format($number);
|
|
// 1,235
|
|
|
|
// Notazione francese
|
|
$nombre_format_francais = number_format($number, 2, ',', ' ');
|
|
// 1 234,56
|
|
|
|
$number = 1234.5678;
|
|
|
|
// notazione inglese senza separatore delle migliaia
|
|
$english_format_number = number_format($number, 2, '.', '');
|
|
// 1234.57
|
|
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
<para>
|
|
Vedere anche <function>sprintf</function>,
|
|
<function>printf</function> e <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:"~/.phpdoc/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
|
|
-->
|