PageRenderTime 62ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/manual/www.php.ru/manual/function.number-format.html

https://github.com/overchuk/vim
HTML | 544 lines | 364 code | 124 blank | 56 comment | 0 complexity | d0d7018de77dfead4829d6abf64b25b5 MD5 | raw file
  1. <!--
  2. HTML dropped by Zend Guard Compressor 4.2
  3. php.ru team: mz, az, yuri, vb, cyxapuk, 440hz, administrator
  4. 2004-2007 (c) expi-web.com
  5. 2007-2008 (c) odware.com
  6. 0101-1010 (с) 440hz
  7. 2b|~2b=?
  8. -->
  9. <!-- EHOT тут всё пожрал ! -->
  10. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  11. <html>
  12. <head>
  13. <link rel="alternate" type="application/rss+xml" title="php.ru/forum - последние сообщения" href="http://www.php.ru/forum/rss.php">
  14. <link rel="SHORTCUT ICON" href="http://www.php.ru/favicon.ico" />
  15. <META name="description" content="php.ru - форум PHP программистов, поиск по всем ресурсам сети, посвященным php">
  16. <meta http-equiv="description" content="php.ru - форум PHP программистов, поиск по всем ресурсам сети, посвященным php">
  17. <META name="keywords" content="php, php5, apache, mysql, session">
  18. <meta http-equiv="keywords" content="php, php5, apache, mysql, session">
  19. <title>php.ru - number_format</title>
  20. <LINK REL="stylesheet" TYPE="text/css" HREF="http://www.php.ru/index.css">
  21. <script language="JavaScript" src="http://www.php.ru/ajax/ajax.js"></script>
  22. </head>
  23. <body>
  24. <table height='100%' width='100%' cellspacing='0' cellpadding='0'>
  25. <tr height='99%' valign='top'>
  26. <td align='center'>
  27. <table style='margin-top: 4px' width=100% cellspacing=0 cellpadding=3>
  28. <tr>
  29. <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> словосочетания &laquo;<a href="/manual/introduction.html" class=lnk>PHP: Hypertext Preprocessor</a>&raquo;</td>
  30. </tr>
  31. </table>
  32. <script language="JavaScript" src="http://www.php.ru/ajax/subsys_ajax.js"></script>
  33. <!--
  34. commet by 440hz
  35. 20.10.2007
  36. <script language="JavaScript" src="http://www.php.ru/ajax/pu_search.js"></script>
  37. -->
  38. <script language="JavaScript" src="http://www.php.ru/ajax/cz.js?a=b"></script>
  39. <table style='margin-top: 5px' width=100% bgcolor=#9999cc cellspacing=0 cellpadding=0 border=0>
  40. <form name=SEARCH method=GET action="http://www.php.ru/search/?SID=vayuk87gidqsub9q" onsubmit="return puSubmit();">
  41. <input type=hidden name=PAGE value=1>
  42. <tr>
  43. <td width='1' valign='middle'>
  44. <a href='/'><img src="http://www.php.ru/;-)/logo.gif" width=133 height=93 alt="php" border=0 hspace=10 vspace=0></a>
  45. </td>
  46. <td width='100%' valign='middle'>
  47. <!--
  48. commet by 440hz
  49. 20.10.2007
  50. <div id='pu_search' class='pu_search'></div>
  51. <div id='pu_search_description' class='pu_search_decription'></div>
  52. -->
  53. <input type=text style='width:99%; margin: 10px' maxlength='200' name='QS' class='in' id='query' autocomplete='off' value="" />
  54. </td>
  55. </tr>
  56. <tr bgcolor='#666699' valign='middle'>
  57. <td style='border-top: 1px solid #333366;'><br /></td>
  58. <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>
  59. </tr>
  60. </form>
  61. </table>
  62. <table id="menu" cellspaciong=0 cellpadding=3>
  63. <tr>
  64. <td><a href="/" class=current>Главная</a></td>
  65. <td><a href="/download/" class=current>Скачать</a></td>
  66. <td><a href="/doc/" class=current>Документация</a></td>
  67. <td><a href="/forum/" class=current>Форум</a></td>
  68. <td width=100% align=right><a href="/phpinfo.html" class=current>phpinfo()</a></td>
  69. </tr>
  70. </table>
  71. <!-- AdRiver code START. Type:728x90 Site: php.ru PZ: 0 BN: 1 -->
  72. <script language="javascript" type="text/javascript"><!--
  73. var RndNum4NoCash = Math.round(Math.random() * 1000000000);
  74. var ar_Tail='unknown'; if (document.referrer) ar_Tail = escape(document.referrer);
  75. document.write(
  76. '<iframe src="http://ad.adriver.ru/cgi-bin/erle.cgi?'
  77. + 'sid=148680&bn=1&target=blank&bt=36&pz=0&rnd=' + RndNum4NoCash + '&tail256=' + ar_Tail
  78. + '" frameborder=0 vspace=0 hspace=0 width=728 height=90 marginwidth=0'
  79. + ' marginheight=0 scrolling=no></iframe>');
  80. //--></script>
  81. <noscript>
  82. <a href="http://ad.adriver.ru/cgi-bin/click.cgi?sid=148680&bn=1&bt=36&pz=0&rnd=1525626915" target=_blank>
  83. <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>
  84. </noscript>
  85. <!-- AdRiver code END -->
  86. <table width='100%' cellspacing='0' cellpadding='0'>
  87. <tr valign='top'>
  88. <td width=100%><div style="margin: 10px 10px 10px 50px;"><center><div style="width: 800px; text-align: left"><DIV
  89. CLASS="NAVHEADER"
  90. ><TABLE
  91. SUMMARY="Header navigation table"
  92. WIDTH="100%"
  93. BORDER="0"
  94. CELLPADDING="0"
  95. CELLSPACING="0"
  96. ><TR
  97. ><TH
  98. COLSPAN="3"
  99. ALIGN="center"
  100. >Руководство по PHP</TH
  101. ></TR
  102. ><TR
  103. ><TD
  104. WIDTH="10%"
  105. ALIGN="left"
  106. VALIGN="bottom"
  107. ><A
  108. HREF="function.nl2br.html"
  109. ACCESSKEY="P"
  110. >Пред.</A
  111. ></TD
  112. ><TD
  113. WIDTH="80%"
  114. ALIGN="center"
  115. VALIGN="bottom"
  116. ></TD
  117. ><TD
  118. WIDTH="10%"
  119. ALIGN="right"
  120. VALIGN="bottom"
  121. ><A
  122. HREF="function.ord.html"
  123. ACCESSKEY="N"
  124. >След.</A
  125. ></TD
  126. ></TR
  127. ></TABLE
  128. ><HR
  129. ALIGN="LEFT"
  130. WIDTH="100%"></DIV
  131. ><H1
  132. ><A
  133. NAME="function.number-format"
  134. ></A
  135. >number_format</H1
  136. ><DIV
  137. CLASS="refnamediv"
  138. ><A
  139. NAME="AEN181939"
  140. ></A
  141. ><P
  142. > (PHP 3, PHP 4, PHP 5)</P
  143. >number_format&nbsp;--&nbsp;Форматирует число с разделением групп</DIV
  144. ><DIV
  145. CLASS="refsect1"
  146. ><A
  147. NAME="AEN181942"
  148. ></A
  149. ><H2
  150. >Описание</H2
  151. >string <B
  152. CLASS="methodname"
  153. >number_format</B
  154. > ( float number [, int decimals] )<BR
  155. ></BR
  156. >string <B
  157. CLASS="methodname"
  158. >number_format</B
  159. > ( float number, int decimals, string dec_point, string thousands_sep )<BR
  160. ></BR
  161. ><P
  162. >&#13; <B
  163. CLASS="function"
  164. >number_format()</B
  165. > возвращает отформатированное число
  166. <VAR
  167. CLASS="parameter"
  168. >number</VAR
  169. >. Функция принимает один, два или
  170. четыре аргумента (не три):
  171. </P
  172. ><P
  173. >&#13; Если передан только один аргумент, <VAR
  174. CLASS="parameter"
  175. >number</VAR
  176. >
  177. будет отформатирован без дробной части, но с запятой (",") между
  178. группами цифр по 3.
  179. </P
  180. ><P
  181. >&#13; Если переданы два аргумента, <VAR
  182. CLASS="parameter"
  183. >number</VAR
  184. > будет
  185. отформатирован с <VAR
  186. CLASS="parameter"
  187. >decimals</VAR
  188. > знаками после точки
  189. (".") и с запятой (",") между группами цифр по 3.
  190. </P
  191. ><P
  192. >&#13; Если переданы все четыре аргумента, <VAR
  193. CLASS="parameter"
  194. >number</VAR
  195. >
  196. будет отформатирован с <VAR
  197. CLASS="parameter"
  198. >decimals</VAR
  199. > знаками после
  200. точки и с разделитилем между группами цифр по 3, при этом в качестве
  201. десятичной точки будет использован <VAR
  202. CLASS="parameter"
  203. >dec_point</VAR
  204. >,
  205. а в качестве разделителя групп - <VAR
  206. CLASS="parameter"
  207. >thousands_sep</VAR
  208. >.
  209. </P
  210. ><P
  211. >&#13; Используется только первый символ строки
  212. <VAR
  213. CLASS="parameter"
  214. >thousands_sep</VAR
  215. >. Например, при передаче
  216. <VAR
  217. CLASS="literal"
  218. >foo</VAR
  219. > в качестве
  220. <VAR
  221. CLASS="parameter"
  222. >thousands_sep</VAR
  223. > для форматирования числа <VAR
  224. CLASS="literal"
  225. >1000</VAR
  226. >,
  227. <B
  228. CLASS="function"
  229. >number_format()</B
  230. > возвращает <VAR
  231. CLASS="literal"
  232. >1f000</VAR
  233. >.
  234. </P
  235. ><P
  236. >&#13; <TABLE
  237. WIDTH="100%"
  238. BORDER="0"
  239. CELLPADDING="0"
  240. CELLSPACING="0"
  241. CLASS="EXAMPLE"
  242. ><TR
  243. ><TD
  244. ><DIV
  245. CLASS="example"
  246. ><A
  247. NAME="AEN181989"
  248. ></A
  249. ><P
  250. ><B
  251. >Пример 1. Пример использования <B
  252. CLASS="function"
  253. >number_format()</B
  254. ></B
  255. ></P
  256. ><P
  257. >&#13; Во Франции обычно используются 2 знака после запятой (','), и
  258. пробел (' ') в качестве разделителя групп. Такое форматирование
  259. получается при использовании следующего кода :
  260. </P
  261. ><TABLE
  262. BORDER="0"
  263. BGCOLOR="#E0E0E0"
  264. CELLPADDING="5"
  265. ><TR
  266. ><TD
  267. ><code><font color="#000000">
  268. <font color="#0000BB">&lt;?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">?&gt;</font>
  269. </font>
  270. </code></TD
  271. ></TR
  272. ></TABLE
  273. ></DIV
  274. ></TD
  275. ></TR
  276. ></TABLE
  277. >
  278. </P
  279. ><P
  280. >&#13; См. также описание функций <A
  281. HREF="function.sprintf.html"
  282. ><B
  283. CLASS="function"
  284. >sprintf()</B
  285. ></A
  286. >,
  287. <A
  288. HREF="function.printf.html"
  289. ><B
  290. CLASS="function"
  291. >printf()</B
  292. ></A
  293. > и <A
  294. HREF="function.sscanf.html"
  295. ><B
  296. CLASS="function"
  297. >sscanf()</B
  298. ></A
  299. >.
  300. </P
  301. ></DIV
  302. ><DIV
  303. CLASS="NAVFOOTER"
  304. ><HR
  305. ALIGN="LEFT"
  306. WIDTH="100%"><TABLE
  307. SUMMARY="Footer navigation table"
  308. WIDTH="100%"
  309. BORDER="0"
  310. CELLPADDING="0"
  311. CELLSPACING="0"
  312. ><TR
  313. ><TD
  314. WIDTH="33%"
  315. ALIGN="left"
  316. VALIGN="top"
  317. ><A
  318. HREF="function.nl2br.html"
  319. ACCESSKEY="P"
  320. >Пред.</A
  321. ></TD
  322. ><TD
  323. WIDTH="34%"
  324. ALIGN="center"
  325. VALIGN="top"
  326. ><A
  327. HREF="index.html"
  328. ACCESSKEY="H"
  329. >Начало</A
  330. ></TD
  331. ><TD
  332. WIDTH="33%"
  333. ALIGN="right"
  334. VALIGN="top"
  335. ><A
  336. HREF="function.ord.html"
  337. ACCESSKEY="N"
  338. >След.</A
  339. ></TD
  340. ></TR
  341. ><TR
  342. ><TD
  343. WIDTH="33%"
  344. ALIGN="left"
  345. VALIGN="top"
  346. >nl2br</TD
  347. ><TD
  348. WIDTH="34%"
  349. ALIGN="center"
  350. VALIGN="top"
  351. ><A
  352. HREF="ref.strings.html"
  353. ACCESSKEY="U"
  354. >Уровень выше</A
  355. ></TD
  356. ><TD
  357. WIDTH="33%"
  358. ALIGN="right"
  359. VALIGN="top"
  360. >ord</TD
  361. ></TR
  362. ></TABLE
  363. ></DIV
  364. ></div></center></div></td>
  365. <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"><!--
  366. google_ad_client = "pub-4093271809023514";
  367. /* 120x600, создано 01.11.2008 */
  368. google_ad_slot = "0438855731";
  369. google_ad_width = 120;
  370. google_ad_height = 600;
  371. //-->
  372. </script>
  373. <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script></div></td>
  374. </tr>
  375. </table>
  376. </td>
  377. </tr>
  378. <tr valign='bottom' height='1%'>
  379. <td> <table width=100% cellspacing=0 cellpadding=5 border=0 bgcolor=#9999CC>
  380. <tr valign=center>
  381. <td class='phpcopyright' width='45%' align='left'>&nbsp;&nbsp;Engine <a href="http://www.mnogosearch.org/">MnoGoSearch</a></td>
  382. <td class='phpcopyright' width='10%' align='center'>2007-2010 &copy <a href="mailto:webmaster@php.ru">PHP.RU</a></td>
  383. <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> &nbsp;&nbsp;</td>
  384. </tr>
  385. </table>
  386. <div style="text-align: right; padding: 5px">
  387. <!--LiveInternet counter-->
  388. <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>');
  389. </script>
  390. <!--/LiveInternet-->
  391. <!-- SpyLOG -->
  392. <script src="http://tools.spylog.ru/counter2.2.js" type="text/javascript" id="spylog_code" counter="830950" ></script>
  393. <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>
  394. </noscript>
  395. <!--/ SpyLOG -->
  396. </div>
  397. </td>
  398. </tr>
  399. </table>
  400. <script>
  401. <!--
  402. document.SEARCH.QS.focus();
  403. // --></script>
  404. <!--
  405. как же вы все это читаете?
  406. 440hz
  407. -->
  408. </body>
  409. </html>