Popular recipes by Alvin Estevez http://code.activestate.com/recipes/users/1177858/2006-07-07T21:37:30-07:00ActiveState Code RecipesPHP Commify Function (PHP)
2006-07-07T21:37:30-07:00Alvin Estevezhttp://code.activestate.com/recipes/users/1177858/http://code.activestate.com/recipes/202051-php-commify-function/
<p style="color: grey">
PHP
recipe 202051
by <a href="/recipes/users/1177858/">Alvin Estevez</a>
(<a href="/recipes/tags/text/">text</a>).
Revision 5.
</p>
<p>This function inserts a comma separator into every 3 digits. For example, 100000 will be 100,000.</p>
<p>Syntax:
commify(Number);</p>
<p>For Example:
commify (100000);
Output will be: $100,000</p>
PHP Dollarfy Function (PHP)
2003-05-24T22:03:47-07:00Alvin Estevezhttp://code.activestate.com/recipes/users/1177858/http://code.activestate.com/recipes/202053-php-dollarfy-function/
<p style="color: grey">
PHP
recipe 202053
by <a href="/recipes/users/1177858/">Alvin Estevez</a>
(<a href="/recipes/tags/text/">text</a>).
Revision 5.
</p>
<p>Dollarfy Function those the following things to a floating point number:</p>
<ol>
<li><p>This function inserts a comma separator into every 3 digits.
For example: 100000.1252 will be 100,000.1252.</p></li>
<li><p>Round to the decimal number to the next significant figure.
For example: 100,000.1252 will be 100,000.13</p></li>
<li><p>Add a dollar sign to the number.
For example: 100,000.13 will be $100,000.13</p></li>
</ol>
<p>Syntax:
dollarfy (Decimal Number, Decimal places);</p>
<p>Example:
dollarfy (100000.1252, 2);</p>
<p>Output will be:
$100,000.13 (Rounded to the second Decimal place)</p>
<p>Note: You will need the commify function for it to work. dollarfy() function needs the commify() function to work.</p>