note 80608 added to function.round

From: Date: Fri, 25 Jan 2008 04:08:55 +0000
Subject: note 80608 added to function.round
Groups: php.notes 
Request: Send a blank email to php-notes+get-135388@lists.php.net to get a copy of this message
/** * 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 ; } ---- Server IP: 203.202.10.60 Probable Submitter: 121.45.182.4 ---- Manual Page -- http://www.php.net/manual/en/function.round.php Edit -- https://master.php.net/note/edit/80608 Del: integrated -- https://master.php.net/note/delete/80608/integrated Del: useless -- https://master.php.net/note/delete/80608/useless Del: bad code -- https://master.php.net/note/delete/80608/bad+code Del: spam -- https://master.php.net/note/delete/80608/spam Del: non-english -- https://master.php.net/note/delete/80608/non-english Del: in docs -- https://master.php.net/note/delete/80608/in+docs Del: other reasons-- https://master.php.net/note/delete/80608 Reject -- https://master.php.net/note/reject/80608 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#135388) next »