Sophie

Sophie

distrib > Mandriva > 9.1 > ppc > by-pkgid > a34ed6838d4b29d38abd504392a4a797 > files > 1849

php-manual-es-4.3.0-2mdk.noarch.rpm

<HTML
><HEAD
><TITLE
>number_format</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
REL="HOME"
TITLE="Manual de PHP"
HREF="index.html"><LINK
REL="UP"
TITLE="Funciones de cadenas"
HREF="ref.strings.html"><LINK
REL="PREVIOUS"
TITLE="nl2br"
HREF="function.nl2br.html"><LINK
REL="NEXT"
TITLE="ord"
HREF="function.ord.html"><META
HTTP-EQUIV="Content-type"
CONTENT="text/html; charset=ISO-8859-1"></HEAD
><BODY
CLASS="refentry"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>Manual de PHP</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="function.nl2br.html"
ACCESSKEY="P"
>Anterior</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="function.ord.html"
ACCESSKEY="N"
>Siguiente</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="function.number-format"
></A
>number_format</H1
><DIV
CLASS="refnamediv"
><A
NAME="AEN75177"
></A
><P
>    (PHP 3, PHP 4 )</P
>number_format&nbsp;--&nbsp;Format a number with grouped thousands</DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN75180"
></A
><H2
>Description</H2
>string <B
CLASS="methodname"
>number_format</B
> ( float number [, int decimals [, string dec_point [, string thousands_sep]]])<BR
></BR
><P
>&#13;     <B
CLASS="function"
>number_format()</B
> returns a formatted version of
     <TT
CLASS="parameter"
><I
>number</I
></TT
>.  This function accepts either one,
     two or four parameters (not three):
    </P
><P
>If only one parameter is given,
     <TT
CLASS="parameter"
><I
>number</I
></TT
> will be formatted without decimals,
     but with a comma (",") between every group of thousands.
    </P
><P
>&#13;     If two parameters are given, <TT
CLASS="parameter"
><I
>number</I
></TT
> will
     be formatted with <TT
CLASS="parameter"
><I
>decimals</I
></TT
> decimals with a
     dot (".") in front, and a comma (",") between every group of
     thousands.
    </P
><P
>&#13;     If all four parameters are given, <TT
CLASS="parameter"
><I
>number</I
></TT
>
     will be formatted with <TT
CLASS="parameter"
><I
>decimals</I
></TT
> decimals,
     <TT
CLASS="parameter"
><I
>dec_point</I
></TT
> instead of a dot (".") before
     the decimals and <TT
CLASS="parameter"
><I
>thousands_sep</I
></TT
> instead of
     a comma (",") between every group of thousands.
    </P
><DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>Nota: </B
>
      Only the first character of <TT
CLASS="parameter"
><I
>thousands_sep</I
></TT
>
      is used.  For example, if you use <TT
CLASS="literal"
>foo</TT
> as
      <TT
CLASS="parameter"
><I
>thousands_sep</I
></TT
> on the number
      <TT
CLASS="literal"
>1000</TT
>, <B
CLASS="function"
>number_format()</B
> will
      return <TT
CLASS="literal"
>1f000</TT
>.
     </P
></BLOCKQUOTE
></DIV
><P
>&#13;    <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN75219"
></A
><P
><B
>Ejemplo 1. <B
CLASS="function"
>number_format()</B
> Example</B
></P
><P
>&#13;      For instance, French notation usually use two decimals,
      comma (',') as decimal separator, and space (' ') as
      thousand separator. This is achieved with this line :
     </P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><PRE
CLASS="php"
>&#60;?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

?&#62;</PRE
></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
    </P
><P
>&#13;     See also: <A
HREF="function.sprintf.html"
><B
CLASS="function"
>sprintf()</B
></A
>,
     <A
HREF="function.printf.html"
><B
CLASS="function"
>printf()</B
></A
> and <A
HREF="function.sscanf.html"
><B
CLASS="function"
>sscanf()</B
></A
>.
    </P
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="function.nl2br.html"
ACCESSKEY="P"
>Anterior</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Inicio</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="function.ord.html"
ACCESSKEY="N"
>Siguiente</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>nl2br</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="ref.strings.html"
ACCESSKEY="U"
>Subir</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>ord</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>