PDA

View Full Version : trimming number in php


aximbigfan
01-28-2008, 01:49 AM
Hi,

I made a log viewer in HP, and one part echoes the size in KB of the log file. I really don't care to know the extra numbers off the KB reading, I just want to know the number to the first place after the decimal point, for example 20.2.

The code that creates the reading just uses filsize() and divides that by 1024, and shoves that into a variable.

Any ideas?

chris

aximbigfan
01-28-2008, 02:00 AM
Sorry guys, I wasn't thinking, just use the round() function :banghead: ..


Chris

Jizzler
01-28-2008, 02:13 AM
number_format($float, 1, '.', '');

round($float, 1);

Either will round to 1 decimal place.