How to round to two decimal places PHP

jeremy picture jeremy · Mar 21, 2011 · Viewed 14.6k times · Source

I would like to round a number to two decimal places in PHP.

PHP code:

$bmi = ($form_state[values][submitted][1] * 703) / 
    ($form_state[values][submitted][10] * $form_state[values][submitted][10]);
$form_values['submitted'][11] = $bmi;
$form_values['submitted_tree'][11] = $bmi;

What is the best way to round the variable $bmi?

Answer

bensiu picture bensiu · Mar 21, 2011