<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Get numeric formatting information</title> </head> <body><div class="manualnavbar" 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" id="refsect1-function.localeconv-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">array</span> <span class="methodname"><strong>localeconv</strong></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" id="refsect1-function.localeconv-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> <span class="function"><strong>localeconv()</strong></span> returns data based upon the current locale as set by <span class="function"><a href="function.setlocale.html" class="function">setlocale()</a></span>. The associative array that is returned contains the following fields: <table class="doctable informaltable"> <thead> <tr> <th>Array element</th> <th>Description</th> </tr> </thead> <tbody class="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> <strong><code>TRUE</code></strong> if currency_symbol precedes a positive value, <strong><code>FALSE</code></strong> if it succeeds one </td> </tr> <tr> <td>p_sep_by_space</td> <td> <strong><code>TRUE</code></strong> if a space separates currency_symbol from a positive value, <strong><code>FALSE</code></strong> otherwise </td> </tr> <tr> <td>n_cs_precedes</td> <td> <strong><code>TRUE</code></strong> if currency_symbol precedes a negative value, <strong><code>FALSE</code></strong> if it succeeds one </td> </tr> <tr> <td>n_sep_by_space</td> <td> <strong><code>TRUE</code></strong> if a space separates currency_symbol from a negative value, <strong><code>FALSE</code></strong> otherwise </td> </tr> <tr style="vertical-align: top;"> <td>p_sign_posn</td> <td> <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 style="vertical-align: top;"> <td>n_sign_posn</td> <td> <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> </table> </p> <p class="para"> The <em>p_sign_posn</em>, and <em>n_sign_posn</em> 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 <strong><code>CHAR_MAX</code></strong>, 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" id="refsect1-function.localeconv-examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example" id="example-4843"> <p><strong>Example #1 <span class="function"><strong>localeconv()</strong></span> example</strong></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 screen"> <div class="cdata"><pre> 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></div> </div> </div> </p> </div> <div class="refsect1 seealso" id="refsect1-function.localeconv-seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"> <span class="function"><a href="function.setlocale.html" class="function" rel="rdfs-seeAlso">setlocale()</a> - Set locale information</span></li> </ul> </p> </div> </div><hr /><div class="manualnavbar" 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></body></html>