Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End how to convert float to this Re: how to convert float to this

#120374
hotpink
Member

This can be reduced to a single operation by passing a 2nd argument to the round() function.

$x = 12.548544444;
$x = round($x, 2);

The “2” tells it to round two places past the decimal.

http://php.net/manual/en/function.round.php