Log in

View Full Version : numbers after .



nicksalad
06-23-2007, 05:09 PM
Hello again, i got this:

$a = "1234560";
$b = $a / "1000000";

echo "$b Millions";

it prints on screen this: 1.234560 Millions

Now the question, how can i print on screen 1.2 Millions instead?

PS: ofcourse $a value allways changes, else i would just echo '1.2 Millions'; directly.

Thanks! :o

thetestingsite
06-23-2007, 05:15 PM
You could use round() (http://www.php.net/round) to do that. Using this technique in your application would be something like so:



$a = "1234560";
$b = $a / "1000000";

echo round($b, 1) . " Millions"; //produces 1.2 Millions


Hope this helps.

nicksalad
06-23-2007, 05:23 PM
Excellent! ;) Thanks you!