D
D
des1roer2015-10-01 06:36:25
PHP
des1roer, 2015-10-01 06:36:25

php how to display zeros after dot?

How can I specify a template for a number and cast it to this form?
for example 2 dots after the comma:
12.23
12.20
12.00
i.e. the number of decimal places is unchanged

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrey Savrasov, 2015-10-01
@alcorn

number_format($number, 2, '.',' ');

I
Ivanq, 2015-10-01
@Ivanq

printf("%01.2f", 100.1);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question