note 4730 deleted from function.round by jeroen

From: Date: Sat, 01 Sep 2001 12:40:45 +0000
Subject: note 4730 deleted from function.round by jeroen
Groups: php.notes 
Request: Send a blank email to php-notes+get-17502@lists.php.net to get a copy of this message
Rounding values f.i. 62.32 --> 62.35 125.15 --> 125.15 36.28 --> 36.30 Next function works for me function rounder($val) { $pos=strrpos($val,"."); $num=substr($val,$pos+2,1); if ($num=="0") { return number_format((round($val*10)/10),2); } elseif ($num>4) { return number_format((round($val*10)/10),2); } else { return number_format((round($val*10)/10)+0.05,2); } } Greetings, Patrick Drummen

« previous php.notes (#17502) next »