PacPac PacPac - 5 months ago 8
PHP Question

Round a number an keep zero in php

With PHP I round a number:

round(1.30, 2)


But I have
1.3
whereas I need
1.30
.

How it is possible please ?

Thanks.

Answer
$unpadded = round(1.30,2);
$padded = sprintf('%0.2f', $unpadded);

Took suggestions from Rizier123.

Comments