note 80608 deleted from function.round by felipe
| From: | felipe@php.net | Date: | Tue, 29 Jan 2008 12:00:31 +0000 |
| Subject: | note 80608 deleted from function.round by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-135535@lists.php.net to get a copy of this message | ||
Note Submitter: goodjamaa at yahoo dot com
----
/**
* Format meny to do decimal places
* @param $money
* @return string money in 2 decimal places
**/
function format_money($money)
{
//get a the default object
$CI =& get_instance();
//declare an array of request and add add basic page info
if(is_float($money))
{
$result=round($money,2);
/**
* Make sure that even after rounding to 2 decimal place,
* the decimal places will still be 2 places
**/
$exploded = explode(".",$result);
if(!empty($exploded[1]) && strlen($exploded[1])==1) $result=$result.'0';
}
else if(is_int($money))
{
if(empty($money)) $result='0.00';
else $result=$money.'.00';
}
else
{
if(empty($money)) $result='0.00';
else $result=$money.'.00';
}
return $result ;
}