<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <HTML ><HEAD ><TITLE >localeconv</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK REL="HOME" TITLE="PHP 手册" HREF="index.html"><LINK REL="UP" TITLE="String 字符串处理函数" HREF="ref.strings.html"><LINK REL="PREVIOUS" TITLE="levenshtein" HREF="function.levenshtein.html"><LINK REL="NEXT" TITLE="ltrim" HREF="function.ltrim.html"><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=UTF-8"></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" >PHP 手册</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="function.levenshtein.html" ACCESSKEY="P" >上一页</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="function.ltrim.html" ACCESSKEY="N" >下一页</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><H1 ><A NAME="function.localeconv" ></A >localeconv</H1 ><DIV CLASS="refnamediv" ><A NAME="AEN225646" ></A ><P > (PHP 4 >= 4.0.5, PHP 5)</P >localeconv -- Get numeric formatting information</DIV ><DIV CLASS="refsect1" ><A NAME="AEN225649" ></A ><H2 >Description</H2 >array <B CLASS="methodname" >localeconv</B > ( void )<BR ></BR ><P > Returns an associative array containing localized numeric and monetary formatting information. </P ><P > <B CLASS="function" >localeconv()</B > returns data based upon the current locale as set by <A HREF="function.setlocale.html" ><B CLASS="function" >setlocale()</B ></A >. The associative array that is returned contains the following fields: <DIV CLASS="informaltable" ><P ></P ><A NAME="AEN225659" ></A ><TABLE BORDER="1" CLASS="CALSTABLE" ><COL><COL><THEAD ><TR ><TH >Array element</TH ><TH >Description</TH ></TR ></THEAD ><TBODY ><TR ><TD >decimal_point</TD ><TD >Decimal point character</TD ></TR ><TR ><TD >thousands_sep</TD ><TD >Thousands separator</TD ></TR ><TR ><TD >grouping</TD ><TD >Array containing numeric groupings</TD ></TR ><TR ><TD >int_curr_symbol</TD ><TD >International currency symbol (i.e. USD)</TD ></TR ><TR ><TD >currency_symbol</TD ><TD >Local currency symbol (i.e. $)</TD ></TR ><TR ><TD >mon_decimal_point</TD ><TD >Monetary decimal point character</TD ></TR ><TR ><TD >mon_thousands_sep</TD ><TD >Monetary thousands separator</TD ></TR ><TR ><TD >mon_grouping</TD ><TD >Array containing monetary groupings</TD ></TR ><TR ><TD >positive_sign</TD ><TD >Sign for positive values</TD ></TR ><TR ><TD >negative_sign</TD ><TD >Sign for negative values</TD ></TR ><TR ><TD >int_frac_digits</TD ><TD >International fractional digits</TD ></TR ><TR ><TD >frac_digits</TD ><TD >Local fractional digits</TD ></TR ><TR ><TD >p_cs_precedes</TD ><TD > <TT CLASS="constant" ><B >TRUE</B ></TT > if currency_symbol precedes a positive value, <TT CLASS="constant" ><B >FALSE</B ></TT > if it succeeds one </TD ></TR ><TR ><TD >p_sep_by_space</TD ><TD > <TT CLASS="constant" ><B >TRUE</B ></TT > if a space separates currency_symbol from a positive value, <TT CLASS="constant" ><B >FALSE</B ></TT > otherwise </TD ></TR ><TR ><TD >n_cs_precedes</TD ><TD > <TT CLASS="constant" ><B >TRUE</B ></TT > if currency_symbol precedes a negative value, <TT CLASS="constant" ><B >FALSE</B ></TT > if it succeeds one </TD ></TR ><TR ><TD >n_sep_by_space</TD ><TD > <TT CLASS="constant" ><B >TRUE</B ></TT > if a space separates currency_symbol from a negative value, <TT CLASS="constant" ><B >FALSE</B ></TT > otherwise </TD ></TR ><TR VALIGN="top" ><TD >p_sign_posn</TD ><TD > <P ></P ><TABLE BORDER="0" ><TBODY ><TR ><TD >0 - Parentheses surround the quantity and currency_symbol</TD ></TR ><TR ><TD >1 - The sign string precedes the quantity and currency_symbol</TD ></TR ><TR ><TD >2 - The sign string succeeds the quantity and currency_symbol</TD ></TR ><TR ><TD >3 - The sign string immediately precedes the currency_symbol</TD ></TR ><TR ><TD >4 - The sign string immediately succeeds the currency_symbol</TD ></TR ></TBODY ></TABLE ><P ></P > </TD ></TR ><TR VALIGN="top" ><TD >n_sign_posn</TD ><TD > <P ></P ><TABLE BORDER="0" ><TBODY ><TR ><TD >0 - Parentheses surround the quantity and currency_symbol</TD ></TR ><TR ><TD >1 - The sign string precedes the quantity and currency_symbol</TD ></TR ><TR ><TD >2 - The sign string succeeds the quantity and currency_symbol</TD ></TR ><TR ><TD >3 - The sign string immediately precedes the currency_symbol</TD ></TR ><TR ><TD >4 - The sign string immediately succeeds the currency_symbol</TD ></TR ></TBODY ></TABLE ><P ></P > </TD ></TR ></TBODY ></TABLE ><P ></P ></DIV > </P ><P > The <TT CLASS="literal" >n_sign_posn</TT >, and <TT CLASS="literal" >n_sign_posn</TT > contain a string of formatting options. Each number representing one of the above listed conditions. </P ><P > The grouping fields contain arrays that define the way numbers should be grouped. For example, the monetary grouping field for the nl_NL locale (in UTF-8 mode with the euro sign), would contain a 2 item array with the values 3 and 3. The higher the index in the array, the farther left the grouping is. If an array element is equal to <TT CLASS="constant" ><B >CHAR_MAX</B ></TT >, no further grouping is done. If an array element is equal to 0, the previous element should be used. </P ><TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><A NAME="AEN225745" ></A ><P ><B >例 1. <B CLASS="function" >localeconv()</B > example</B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><code><font color="#000000"> <font color="#0000BB"><?php<br /></font><font color="#007700">if (</font><font color="#0000BB">false </font><font color="#007700">!== </font><font color="#0000BB">setlocale</font><font color="#007700">(</font><font color="#0000BB">LC_ALL</font><font color="#007700">, </font><font color="#DD0000">'nl_NL.UTF-8@euro'</font><font color="#007700">)) {<br /> </font><font color="#0000BB">$locale_info </font><font color="#007700">= </font><font color="#0000BB">localeconv</font><font color="#007700">();<br /> </font><font color="#0000BB">print_r</font><font color="#007700">(</font><font color="#0000BB">$locale_info</font><font color="#007700">);<br />}<br /></font><font color="#0000BB">?></font> </font> </code></TD ></TR ></TABLE ><P >上例将输出:</P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><PRE CLASS="screen" >Array ( [decimal_point] => . [thousands_sep] => [int_curr_symbol] => EUR [currency_symbol] => € [mon_decimal_point] => , [mon_thousands_sep] => [positive_sign] => [negative_sign] => - [int_frac_digits] => 2 [frac_digits] => 2 [p_cs_precedes] => 1 [p_sep_by_space] => 1 [n_cs_precedes] => 1 [n_sep_by_space] => 1 [p_sign_posn] => 1 [n_sign_posn] => 2 [grouping] => Array ( ) [mon_grouping] => Array ( [0] => 3 [1] => 3 ) )</PRE ></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE ><P > See also <A HREF="function.setlocale.html" ><B CLASS="function" >setlocale()</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.levenshtein.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.ltrim.html" ACCESSKEY="N" >下一页</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >levenshtein</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="ref.strings.html" ACCESSKEY="U" >上一级</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >ltrim</TD ></TR ></TABLE ></DIV ></BODY ></HTML >