Page 1 of 1

number round up (solved)

Posted: Tue Aug 29, 2006 10:27 am
by MaxInfinity
Hi guys

I'm retrieving data from a mysql database into a php page. The database stores the length of an mp3 album as a number I.E. 8069 I want to I want to show this as hours minutes, so I use the following code to divide it by 60.

Code: Select all

//convert total album length into hours and minutes
$totallength = $row[TotalLength];
$lengthconvert = $totallength/60;
echo "$lengthconvert";
//end
but this gives me the result 134.483333333 how can I round this off to 134.48.

Thanx in advance.

Ok I found what I was looking for.

Code: Select all

//convert total album length into hours and minutes
$totallength = $row[TotalLength];
$lengthconvert = $totallength/60;
$round=round($lengthconvert,2); 
echo "$round";
//end

Posted: Tue Aug 29, 2006 10:35 am
by Luke
round()

Posted: Tue Aug 29, 2006 10:36 am
by MaxInfinity
thanx ninja found it, you must have been posting as I was editing