PHP DIVISION OPERATOR
Moderator: General Moderators
PHP DIVISION OPERATOR
I am fairly new to php. I want to know the easiest way of getting a result like 7.9 or 9.5 or 8.3 A whole number with one decimal place using the division operator. Is this hard to code? Please help.
no, not hard to do
see also:
http://php.net/number_format
http://php.net/printf
Code: Select all
<?php
$number = 22.0 / 7.0; // a float-value
echo number_format($number, 1);
// or
printf("%.1f", $number);
?>http://php.net/number_format
http://php.net/printf