mirror of
https://github.com/php/doc-es.git
synced 2026-03-26 16:32:13 +01:00
git-svn-id: https://svn.php.net/repository/phpdoc/es/trunk@333743 c90b9560-bf6c-de11-be94-00142212c4b1
192 lines
5.5 KiB
XML
192 lines
5.5 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<!-- EN-Revision: 9905374cd0b37a55542a68eedac9cf59521f59c9 Maintainer: seros Status: ready -->
|
|
<!-- Reviewed: yes Maintainer: seros -->
|
|
<refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.number-format" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
<refnamediv>
|
|
<refname>number_format</refname>
|
|
<refpurpose>Formatear un número con los millares agrupados</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&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><initializer>0</initializer></methodparam>
|
|
</methodsynopsis>
|
|
<methodsynopsis>
|
|
<type>string</type><methodname>number_format</methodname>
|
|
<methodparam><type>float</type><parameter>number</parameter></methodparam>
|
|
<methodparam><type>int</type><parameter>decimals</parameter><initializer>0</initializer></methodparam>
|
|
<methodparam><type>string</type><parameter>dec_point</parameter><initializer>"."</initializer></methodparam>
|
|
<methodparam><type>string</type><parameter>thousands_sep</parameter><initializer>","</initializer></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
Esta función acepta uno, dos, o cuatro parámetros (no tres):
|
|
</para>
|
|
<para>
|
|
Si solo se proporciona un parámetro,
|
|
<parameter>number</parameter> será formateado sin decimales,
|
|
pero con una coma (",") entre cada grupo de millares.
|
|
</para>
|
|
<para>
|
|
Si se proporcionan dos parámetros, <parameter>number</parameter> será
|
|
formateado con tantos decimales como se hayan definido en <parameter>decimals</parameter>
|
|
colocando un punto (".") delante, y una coma (",") entre cada grupo de
|
|
millares.
|
|
</para>
|
|
<para>
|
|
Si se proporcionan los cuatro parámetros, <parameter>number</parameter>
|
|
será formateado con tantos decimales como hayamos definido en <parameter>decimals</parameter>,
|
|
<parameter>dec_point</parameter> sustituirá al punto (".") como
|
|
seperador de los decimales y el separador por defecto de los millares, la coma (","),
|
|
será sustituida por <parameter>thousands_sep</parameter>.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>number</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
El número al que dar formato.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>decimals</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Establece el número de puntos decimales.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>dec_point</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Establece el separador para los decimales.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>thousands_sep</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Establece el separador para los millares.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
Una versión formateada de <parameter>number</parameter>.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="changelog">
|
|
&reftitle.changelog;
|
|
<para>
|
|
<informaltable>
|
|
<tgroup cols="2">
|
|
<thead>
|
|
<row>
|
|
<entry>&Version;</entry>
|
|
<entry>&Description;</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry>5.4.0</entry>
|
|
<entry>
|
|
Esta función ahora admite múltiples bytes en
|
|
<parameter>dec_point</parameter> y
|
|
<parameter>thousands_sep</parameter>. En versiones anteriors solamente
|
|
se utilizaba el primer byte de cada separador.
|
|
</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</informaltable>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title>Ejemplo de <function>number_format</function></title>
|
|
<para>
|
|
Por ejemplo, la notación francesa suele utilizar dos decimales,
|
|
una coma (',') como separador decimal y el espacio (' ') como
|
|
separador de millares. Esto consigue esto mediante las siguientes líneas:
|
|
</para>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
|
|
$número = 1234.56;
|
|
|
|
// notación inglesa (por defecto)
|
|
$número_formato_inglés = number_format($número);
|
|
// 1,235
|
|
|
|
// notación francesa
|
|
$nombre_format_francais = number_format($número, 2, ',', ' ');
|
|
// 1 234,56
|
|
|
|
$número = 1234.5678;
|
|
|
|
// notación inglesa sin separador de millares
|
|
$english_format_number = number_format($número, 2, '.', '');
|
|
// 1234.57
|
|
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><function>money_format</function></member>
|
|
<member><function>sprintf</function></member>
|
|
<member><function>printf</function></member>
|
|
<member><function>sscanf</function></member>
|
|
</simplelist>
|
|
</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
|
|
-->
|