alin19 Posted January 7, 2008 Share Posted January 7, 2008 <?php if($_SERVER['REQUEST_METHOD'] == 'POST') { $a = $_POST['unu']; $b = $_POST['doi']; $c = $_POST['trei']; $d = $_POST['patru']; $x = ($a*100+$d*$c)/(100+$c+$b); } ?> <html> <table> <form> <td height="35" valign="" align="center"><font color="green" size="8" ><?php if(isset($x)) { echo $x; } ?> </font></td> </tr> </table> </form> </html> i get a number like this : 2.9150943396226 i want to get something like this : 2.91 what i must add? Quote Link to comment https://forums.phpfreaks.com/topic/84842-solved-limiting-the-zecimal-numbers/ Share on other sites More sharing options...
stuffradio Posted January 7, 2008 Share Posted January 7, 2008 Change $x = ($a*100+$d*$c)/(100+$c+$b); To: $x = ($a*100+$d*$c)/(100+$c+$b); $x = number_format($x, 2); Quote Link to comment https://forums.phpfreaks.com/topic/84842-solved-limiting-the-zecimal-numbers/#findComment-432520 Share on other sites More sharing options...
alin19 Posted January 7, 2008 Author Share Posted January 7, 2008 10x Quote Link to comment https://forums.phpfreaks.com/topic/84842-solved-limiting-the-zecimal-numbers/#findComment-432522 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.