📄 function.localeconv.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title>Get numeric formatting information</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.levenshtein.html">levenshtein</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.ltrim.html">ltrim</a></div> <div class="up"><a href="ref.strings.html">String Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div id="function.localeconv" class="refentry"> <div class="refnamediv"> <h1 class="refname">localeconv</h1> <p class="verinfo">(PHP 4 >= 4.0.5, PHP 5)</p><p class="refpurpose"><span class="refname">localeconv</span> — <span class="dc-title">Get numeric formatting information</span></p> </div> <div class="refsect1 description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">array</span> <span class="methodname"><b><b>localeconv</b></b></span> ( <span class="methodparam">void</span> )</div> <p class="para rdfs-comment"> Returns an associative array containing localized numeric and monetary formatting information. </p> </div> <div class="refsect1 returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> <b>localeconv()</b> returns data based upon the current locale as set by <a href="function.setlocale.html" class="function">setlocale()</a>. The associative array that is returned contains the following fields: <table class="informaltable"> <colgroup> <thead valign="middle"> <tr valign="middle"> <th colspan="1">Array element</th> <th colspan="1">Description</th> </tr> </thead> <tbody valign="middle" class="tbody"> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">decimal_point</td> <td colspan="1" rowspan="1" align="left">Decimal point character</td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">thousands_sep</td> <td colspan="1" rowspan="1" align="left">Thousands separator</td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">grouping</td> <td colspan="1" rowspan="1" align="left">Array containing numeric groupings</td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">int_curr_symbol</td> <td colspan="1" rowspan="1" align="left">International currency symbol (i.e. USD)</td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">currency_symbol</td> <td colspan="1" rowspan="1" align="left">Local currency symbol (i.e. $)</td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">mon_decimal_point</td> <td colspan="1" rowspan="1" align="left">Monetary decimal point character</td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">mon_thousands_sep</td> <td colspan="1" rowspan="1" align="left">Monetary thousands separator</td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">mon_grouping</td> <td colspan="1" rowspan="1" align="left">Array containing monetary groupings</td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">positive_sign</td> <td colspan="1" rowspan="1" align="left">Sign for positive values</td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">negative_sign</td> <td colspan="1" rowspan="1" align="left">Sign for negative values</td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">int_frac_digits</td> <td colspan="1" rowspan="1" align="left">International fractional digits</td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">frac_digits</td> <td colspan="1" rowspan="1" align="left">Local fractional digits</td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">p_cs_precedes</td> <td colspan="1" rowspan="1" align="left"> <b><tt>TRUE</tt></b> if currency_symbol precedes a positive value, <b><tt>FALSE</tt></b> if it succeeds one </td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">p_sep_by_space</td> <td colspan="1" rowspan="1" align="left"> <b><tt>TRUE</tt></b> if a space separates currency_symbol from a positive value, <b><tt>FALSE</tt></b> otherwise </td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">n_cs_precedes</td> <td colspan="1" rowspan="1" align="left"> <b><tt>TRUE</tt></b> if currency_symbol precedes a negative value, <b><tt>FALSE</tt></b> if it succeeds one </td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">n_sep_by_space</td> <td colspan="1" rowspan="1" align="left"> <b><tt>TRUE</tt></b> if a space separates currency_symbol from a negative value, <b><tt>FALSE</tt></b> otherwise </td> </tr> <tr valign="top"> <td colspan="1" rowspan="1" align="left">p_sign_posn</td> <td colspan="1" rowspan="1" align="left"> <ul class="simplelist"> <li class="member">0 - Parentheses surround the quantity and currency_symbol</li> <li class="member">1 - The sign string precedes the quantity and currency_symbol</li> <li class="member">2 - The sign string succeeds the quantity and currency_symbol</li> <li class="member">3 - The sign string immediately precedes the currency_symbol</li> <li class="member">4 - The sign string immediately succeeds the currency_symbol</li> </ul> </td> </tr> <tr valign="top"> <td colspan="1" rowspan="1" align="left">n_sign_posn</td> <td colspan="1" rowspan="1" align="left"> <ul class="simplelist"> <li class="member">0 - Parentheses surround the quantity and currency_symbol</li> <li class="member">1 - The sign string precedes the quantity and currency_symbol</li> <li class="member">2 - The sign string succeeds the quantity and currency_symbol</li> <li class="member">3 - The sign string immediately precedes the currency_symbol</li> <li class="member">4 - The sign string immediately succeeds the currency_symbol</li> </ul> </td> </tr> </tbody> </colgroup> </table> </p> <p class="para"> The <i>p_sign_posn</i>, and <i>n_sign_posn</i> contain a string of formatting options. Each number representing one of the above listed conditions. </p> <p class="para"> 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 <b><tt>CHAR_MAX</tt></b>, no further grouping is done. If an array element is equal to 0, the previous element should be used. </p> </div> <div class="refsect1 examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example"> <p><b>Example #1 <b>localeconv()</b> example</b></p> <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB"><?php<br /></span><span style="color: #007700">if (</span><span style="color: #0000BB">false </span><span style="color: #007700">!== </span><span style="color: #0000BB">setlocale</span><span style="color: #007700">(</span><span style="color: #0000BB">LC_ALL</span><span style="color: #007700">, </span><span style="color: #DD0000">'nl_NL.UTF-8@euro'</span><span style="color: #007700">)) {<br /> </span><span style="color: #0000BB">$locale_info </span><span style="color: #007700">= </span><span style="color: #0000BB">localeconv</span><span style="color: #007700">();<br /> </span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">$locale_info</span><span style="color: #007700">);<br />}<br /></span><span style="color: #0000BB">?></span></span></code></div> </div> <div class="example-contents"><p>The above example will output:</p></div> <div class="example-contents"><pre><div class="cdata"><pre>Array( [decimal_point] => . [thousands_sep] => [int_curr_symbol] => EUR [currency_symbol] => 鈧
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -