/manual/www.php.ru/manual/function.number-format.html
HTML | 544 lines | 364 code | 124 blank | 56 comment | 0 complexity | d0d7018de77dfead4829d6abf64b25b5 MD5 | raw file
- <!--
- HTML dropped by Zend Guard Compressor 4.2
- php.ru team: mz, az, yuri, vb, cyxapuk, 440hz, administrator
- 2004-2007 (c) expi-web.com
- 2007-2008 (c) odware.com
- 0101-1010 (с) 440hz
- 2b|~2b=?
- -->
- <!-- EHOT тут всё пожрал ! -->
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
- <html>
- <head>
- <link rel="alternate" type="application/rss+xml" title="php.ru/forum - последние сообщения" href="http://www.php.ru/forum/rss.php">
- <link rel="SHORTCUT ICON" href="http://www.php.ru/favicon.ico" />
- <META name="description" content="php.ru - форум PHP программистов, поиск по всем ресурсам сети, посвященным php">
- <meta http-equiv="description" content="php.ru - форум PHP программистов, поиск по всем ресурсам сети, посвященным php">
- <META name="keywords" content="php, php5, apache, mysql, session">
- <meta http-equiv="keywords" content="php, php5, apache, mysql, session">
- <title>php.ru - number_format</title>
- <LINK REL="stylesheet" TYPE="text/css" HREF="http://www.php.ru/index.css">
- <script language="JavaScript" src="http://www.php.ru/ajax/ajax.js"></script>
- </head>
- <body>
- <table height='100%' width='100%' cellspacing='0' cellpadding='0'>
- <tr height='99%' valign='top'>
- <td align='center'>
-
- <table style='margin-top: 4px' width=100% cellspacing=0 cellpadding=3>
- <tr>
- <td>PHP - <a href="http://ru.wikipedia.org/wiki/%D0%A0%D0%B5%D0%BA%D1%83%D1%80%D1%81%D0%B8%D0%B2%D0%BD%D1%8B%D0%B9_%D0%B0%D0%BA%D1%80%D0%BE%D0%BD%D0%B8%D0%BC" target=_blank class=lnk>рекурсивный акроним</a> словосочетания «<a href="/manual/introduction.html" class=lnk>PHP: Hypertext Preprocessor</a>»</td>
- </tr>
- </table>
- <script language="JavaScript" src="http://www.php.ru/ajax/subsys_ajax.js"></script>
- <!--
- commet by 440hz
- 20.10.2007
- <script language="JavaScript" src="http://www.php.ru/ajax/pu_search.js"></script>
- -->
- <script language="JavaScript" src="http://www.php.ru/ajax/cz.js?a=b"></script>
- <table style='margin-top: 5px' width=100% bgcolor=#9999cc cellspacing=0 cellpadding=0 border=0>
- <form name=SEARCH method=GET action="http://www.php.ru/search/?SID=vayuk87gidqsub9q" onsubmit="return puSubmit();">
- <input type=hidden name=PAGE value=1>
- <tr>
- <td width='1' valign='middle'>
- <a href='/'><img src="http://www.php.ru/;-)/logo.gif" width=133 height=93 alt="php" border=0 hspace=10 vspace=0></a>
- </td>
- <td width='100%' valign='middle'>
- <!--
-
- commet by 440hz
- 20.10.2007
- <div id='pu_search' class='pu_search'></div>
- <div id='pu_search_description' class='pu_search_decription'></div>
-
- -->
- <input type=text style='width:99%; margin: 10px' maxlength='200' name='QS' class='in' id='query' autocomplete='off' value="" />
- </td>
- </tr>
- <tr bgcolor='#666699' valign='middle'>
- <td style='border-top: 1px solid #333366;'><br /></td>
- <td style='border-top: 1px solid #333366;'><div style="padding: 4px 4px 4px 10px; height: 24px; color: #CCCCFF;" id="stat">Хто там?<script>doLoadCZ('stat','stat');</script></div></td>
- </tr>
- </form>
- </table>
- <table id="menu" cellspaciong=0 cellpadding=3>
- <tr>
- <td><a href="/" class=current>Главная</a></td>
- <td><a href="/download/" class=current>Скачать</a></td>
- <td><a href="/doc/" class=current>Документация</a></td>
- <td><a href="/forum/" class=current>Форум</a></td>
- <td width=100% align=right><a href="/phpinfo.html" class=current>phpinfo()</a></td>
- </tr>
- </table>
-
- <!-- AdRiver code START. Type:728x90 Site: php.ru PZ: 0 BN: 1 -->
- <script language="javascript" type="text/javascript"><!--
- var RndNum4NoCash = Math.round(Math.random() * 1000000000);
- var ar_Tail='unknown'; if (document.referrer) ar_Tail = escape(document.referrer);
- document.write(
- '<iframe src="http://ad.adriver.ru/cgi-bin/erle.cgi?'
- + 'sid=148680&bn=1&target=blank&bt=36&pz=0&rnd=' + RndNum4NoCash + '&tail256=' + ar_Tail
- + '" frameborder=0 vspace=0 hspace=0 width=728 height=90 marginwidth=0'
- + ' marginheight=0 scrolling=no></iframe>');
- //--></script>
- <noscript>
- <a href="http://ad.adriver.ru/cgi-bin/click.cgi?sid=148680&bn=1&bt=36&pz=0&rnd=1525626915" target=_blank>
- <img src="http://ad.adriver.ru/cgi-bin/rle.cgi?sid=148680&bn=1&bt=36&pz=0&rnd=1525626915" alt="-AdRiver-" border=0 width=728 height=90></a>
- </noscript>
- <!-- AdRiver code END -->
- <table width='100%' cellspacing='0' cellpadding='0'>
- <tr valign='top'>
- <td width=100%><div style="margin: 10px 10px 10px 50px;"><center><div style="width: 800px; text-align: left"><DIV
- CLASS="NAVHEADER"
- ><TABLE
- SUMMARY="Header navigation table"
- WIDTH="100%"
- BORDER="0"
- CELLPADDING="0"
- CELLSPACING="0"
- ><TR
- ><TH
- COLSPAN="3"
- ALIGN="center"
- >Руководство по PHP</TH
- ></TR
- ><TR
- ><TD
- WIDTH="10%"
- ALIGN="left"
- VALIGN="bottom"
- ><A
- HREF="function.nl2br.html"
- ACCESSKEY="P"
- >Пред.</A
- ></TD
- ><TD
- WIDTH="80%"
- ALIGN="center"
- VALIGN="bottom"
- ></TD
- ><TD
- WIDTH="10%"
- ALIGN="right"
- VALIGN="bottom"
- ><A
- HREF="function.ord.html"
- ACCESSKEY="N"
- >След.</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="AEN181939"
- ></A
- ><P
- > (PHP 3, PHP 4, PHP 5)</P
- >number_format -- Форматирует число с разделением групп</DIV
- ><DIV
- CLASS="refsect1"
- ><A
- NAME="AEN181942"
- ></A
- ><H2
- >Описание</H2
- >string <B
- CLASS="methodname"
- >number_format</B
- > ( float number [, int decimals] )<BR
- ></BR
- >string <B
- CLASS="methodname"
- >number_format</B
- > ( float number, int decimals, string dec_point, string thousands_sep )<BR
- ></BR
- ><P
- > <B
- CLASS="function"
- >number_format()</B
- > возвращает отформатированное число
- <VAR
- CLASS="parameter"
- >number</VAR
- >. Функция принимает один, два или
- четыре аргумента (не три):
- </P
- ><P
- > Если передан только один аргумент, <VAR
- CLASS="parameter"
- >number</VAR
- >
- будет отформатирован без дробной части, но с запятой (",") между
- группами цифр по 3.
- </P
- ><P
- > Если переданы два аргумента, <VAR
- CLASS="parameter"
- >number</VAR
- > будет
- отформатирован с <VAR
- CLASS="parameter"
- >decimals</VAR
- > знаками после точки
- (".") и с запятой (",") между группами цифр по 3.
- </P
- ><P
- > Если переданы все четыре аргумента, <VAR
- CLASS="parameter"
- >number</VAR
- >
- будет отформатирован с <VAR
- CLASS="parameter"
- >decimals</VAR
- > знаками после
- точки и с разделитилем между группами цифр по 3, при этом в качестве
- десятичной точки будет использован <VAR
- CLASS="parameter"
- >dec_point</VAR
- >,
- а в качестве разделителя групп - <VAR
- CLASS="parameter"
- >thousands_sep</VAR
- >.
- </P
- ><P
- > Используется только первый символ строки
- <VAR
- CLASS="parameter"
- >thousands_sep</VAR
- >. Например, при передаче
- <VAR
- CLASS="literal"
- >foo</VAR
- > в качестве
- <VAR
- CLASS="parameter"
- >thousands_sep</VAR
- > для форматирования числа <VAR
- CLASS="literal"
- >1000</VAR
- >,
- <B
- CLASS="function"
- >number_format()</B
- > возвращает <VAR
- CLASS="literal"
- >1f000</VAR
- >.
- </P
- ><P
- > <TABLE
- WIDTH="100%"
- BORDER="0"
- CELLPADDING="0"
- CELLSPACING="0"
- CLASS="EXAMPLE"
- ><TR
- ><TD
- ><DIV
- CLASS="example"
- ><A
- NAME="AEN181989"
- ></A
- ><P
- ><B
- >Пример 1. Пример использования <B
- CLASS="function"
- >number_format()</B
- ></B
- ></P
- ><P
- > Во Франции обычно используются 2 знака после запятой (','), и
- пробел (' ') в качестве разделителя групп. Такое форматирование
- получается при использовании следующего кода :
- </P
- ><TABLE
- BORDER="0"
- BGCOLOR="#E0E0E0"
- CELLPADDING="5"
- ><TR
- ><TD
- ><code><font color="#000000">
- <font color="#0000BB"><?php<br /><br />$number </font><font color="#007700">= </font><font color="#0000BB">1234.56</font><font color="#007700">;<br /><br /></font><font color="#FF8000">// английский формат (по умолчанию)<br /></font><font color="#0000BB">$english_format_number </font><font color="#007700">= </font><font color="#0000BB">number_format</font><font color="#007700">(</font><font color="#0000BB">$number</font><font color="#007700">);<br /></font><font color="#FF8000">// 1,234<br /><br />// французский формат<br /></font><font color="#0000BB">$nombre_format_francais </font><font color="#007700">= </font><font color="#0000BB">number_format</font><font color="#007700">(</font><font color="#0000BB">$number</font><font color="#007700">, </font><font color="#0000BB">2</font><font color="#007700">, </font><font color="#DD0000">','</font><font color="#007700">, </font><font color="#DD0000">' '</font><font color="#007700">);<br /></font><font color="#FF8000">// 1 234,56<br /><br /></font><font color="#0000BB">$number </font><font color="#007700">= </font><font color="#0000BB">1234.5678</font><font color="#007700">;<br /><br /></font><font color="#FF8000">// английский формат без разделителей групп<br /></font><font color="#0000BB">$english_format_number </font><font color="#007700">= </font><font color="#0000BB">number_format</font><font color="#007700">(</font><font color="#0000BB">$number</font><font color="#007700">, </font><font color="#0000BB">2</font><font color="#007700">, </font><font color="#DD0000">'.'</font><font color="#007700">, </font><font color="#DD0000">''</font><font color="#007700">);<br /></font><font color="#FF8000">// 1234.57<br /><br /></font><font color="#0000BB">?></font>
- </font>
- </code></TD
- ></TR
- ></TABLE
- ></DIV
- ></TD
- ></TR
- ></TABLE
- >
- </P
- ><P
- > См. также описание функций <A
- HREF="function.sprintf.html"
- ><B
- CLASS="function"
- >sprintf()</B
- ></A
- >,
- <A
- HREF="function.printf.html"
- ><B
- CLASS="function"
- >printf()</B
- ></A
- > и <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"
- >Пред.</A
- ></TD
- ><TD
- WIDTH="34%"
- ALIGN="center"
- VALIGN="top"
- ><A
- HREF="index.html"
- ACCESSKEY="H"
- >Начало</A
- ></TD
- ><TD
- WIDTH="33%"
- ALIGN="right"
- VALIGN="top"
- ><A
- HREF="function.ord.html"
- ACCESSKEY="N"
- >След.</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"
- >Уровень выше</A
- ></TD
- ><TD
- WIDTH="33%"
- ALIGN="right"
- VALIGN="top"
- >ord</TD
- ></TR
- ></TABLE
- ></DIV
- ></div></center></div></td>
- <td><div style="display:none; width:200px;" id="o3" name="o3"><script charset="windows-1251" type="text/javascript" src="http://www.ozon.ru/PartnerTwinerNew.aspx?revident=bea9126b-c8e1-4bf5-b6d8-9a057f8feac6" ></script></div><script>o = document.getElementById('o3'); if(o) { var s = o.innerHTML; s = s.replace(/F6F6F6/gi,"FFFFFF"); o.innerHTML = s.replace(/padding-top: 10px; padding-bottom: 10px;/,"display:none;"); o.style.display = 'block'; } </script><br><div style="margin: 10px;"><script type="text/javascript"><!--
- google_ad_client = "pub-4093271809023514";
- /* 120x600, создано 01.11.2008 */
- google_ad_slot = "0438855731";
- google_ad_width = 120;
- google_ad_height = 600;
- //-->
- </script>
- <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script></div></td>
- </tr>
- </table>
- </td>
- </tr>
- <tr valign='bottom' height='1%'>
- <td> <table width=100% cellspacing=0 cellpadding=5 border=0 bgcolor=#9999CC>
- <tr valign=center>
- <td class='phpcopyright' width='45%' align='left'> Engine <a href="http://www.mnogosearch.org/">MnoGoSearch</a></td>
- <td class='phpcopyright' width='10%' align='center'>2007-2010 © <a href="mailto:webmaster@php.ru">PHP.RU</a></td>
- <td class='phpcopyright' width='45%' align='right' >Powered by <a target="_blank" href="http://odware.ru">ODware</a> <a HREF="http://440hz.ru">440Hz</a> </td>
- </tr>
- </table>
- <div style="text-align: right; padding: 5px">
- <!--LiveInternet counter-->
- <script type="text/javascript">document.write('<a href="http://www.liveinternet.ru/click" target=_blank><img src="http://counter.yadro.ru/hit?t53.6;r' + escape(document.referrer) + ((typeof(screen)=='undefined')?'':';s'+screen.width+'*'+screen.height+'*'+(screen.colorDepth?screen.colorDepth:screen.pixelDepth)) + ';u' + escape(document.URL) +';i' + escape('Жж'+document.title.substring(0,80)) + ';' + Math.random() + '" border=0 width=88 height=31 alt="" title="LiveInternet: показано число просмотров и посетителей за 24 часа"><\/a>');
- </script>
- <!--/LiveInternet-->
- <!-- SpyLOG -->
- <script src="http://tools.spylog.ru/counter2.2.js" type="text/javascript" id="spylog_code" counter="830950" ></script>
- <noscript><a href="http://u8309.50.spylog.com/cnt?cid=830950&f=3&p=0" target="_blank"><img src="http://u8309.50.spylog.com/cnt?cid=830950&p=0&f=4" alt='SpyLOG' border='0' width=88 height=31 ></a>
- </noscript>
- <!--/ SpyLOG -->
- </div>
- </td>
- </tr>
- </table>
- <script>
- <!--
- document.SEARCH.QS.focus();
- // --></script>
- <!--
- как же вы все это читаете?
- 440hz
- -->
- </body>
- </html>