number round up (solved)

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
MaxInfinity
Forum Newbie
Posts: 4
Joined: Thu Aug 24, 2006 5:14 am

number round up (solved)

Post 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
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

round()
MaxInfinity
Forum Newbie
Posts: 4
Joined: Thu Aug 24, 2006 5:14 am

Post by MaxInfinity »

thanx ninja found it, you must have been posting as I was editing
Post Reply