mirror of
https://github.com/php/doc-ja.git
synced 2026-04-28 18:43:16 +02:00
157bd55a0b
git-svn-id: https://svn.php.net/repository/phpdoc/ja/trunk@199046 c90b9560-bf6c-de11-be94-00142212c4b1
110 lines
3.8 KiB
XML
110 lines
3.8 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision: 1.2 $ -->
|
|
<!-- EN-Revision: 1.8 Maintainer: shimooka Status: ready -->
|
|
<!-- splitted from ./en/functions/math.xml, last change in rev 1.2 -->
|
|
<refentry id="function.number-format">
|
|
<refnamediv>
|
|
<refname>number_format</refname>
|
|
<refpurpose>数字を千位毎にグループ化してフォーマットする</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>説明</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>
|
|
<function>number_format</function>
|
|
は <parameter>number</parameter> をフォーマットして返します。
|
|
この機能は 1 つか 2 つもしくは 4 つのパラメータを受け取ります
|
|
(3 つはありません) :
|
|
</para>
|
|
<para>パラメータが 1 つだけ渡された場合、
|
|
<parameter>number</parameter> は千位毎にカンマ (",") が追加され、
|
|
少数なしでフォーマットされます。
|
|
</para>
|
|
<para>
|
|
パラメータが 2 つ渡された場合、<parameter>number</parameter>
|
|
は <parameter>decimals</parameter> 桁の少数の前にドット (".") 、
|
|
千位毎にカンマ (",") が追加されてフォーマットされます。
|
|
</para>
|
|
<para>
|
|
パラメータが 4 つ全て渡された場合、<parameter>number</parameter>
|
|
はドット (".") の代わりに <parameter>dec_point</parameter> が
|
|
<parameter>decimals</parameter> 桁の少数の前に、千位毎にカンマ
|
|
(",") の代わりに <parameter>thousands_sep</parameter>
|
|
が追加されてフォーマットされます。
|
|
</para>
|
|
<para>
|
|
<parameter>thousands_sep</parameter> は最初の文字だけが使用されます。
|
|
例えば、数字の <literal>1000</literal> に対する
|
|
<parameter>thousands_sep</parameter> として <literal>bar</literal>
|
|
を使用した場合、<function>number_format</function> は
|
|
<literal>1b000</literal> を返します。
|
|
</para>
|
|
<para>
|
|
<example>
|
|
<title><function>number_format</function> の例</title>
|
|
<para>
|
|
例えばフランスの表記法では、通常カンマ (",")
|
|
を少数の区切りとした二桁の少数と、千位毎の区切りとしてスペース
|
|
(" ") が使用されます。これは次のように処理することができます:
|
|
</para>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
|
|
$number = 1234.56;
|
|
|
|
// 英語での表記 (デフォルト)
|
|
$english_format_number = number_format($number);
|
|
// 1,235
|
|
|
|
// フランスの表記
|
|
$nombre_format_francais = number_format($number, 2, ',', ' ');
|
|
// 1 234,56
|
|
|
|
$number = 1234.5678;
|
|
|
|
// 千位毎の区切りがない英語での表記
|
|
$english_format_number = number_format($number, 2, '.', '');
|
|
// 1234.57
|
|
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
<para>
|
|
<function>sprintf</function>,
|
|
<function>printf</function>,
|
|
<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:"../../../../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
|
|
-->
|