Add a zero when there is only 1 decimal

Asked

Viewed 52 times

0

Good staff, I have a system for issuing electronic invoice, there is a government rule where the values of duplicates(installments) must possess exact 2 decimal places. I use number_format to declare that it shows only two decimal places, but when the number is an integer decimal it does not show a zero, example:

Installment 1 : R$ 140,11 Installment 2: R$ 140,10

What happens is that when shows the plot 2 it shows me R $ 140,1 , IE, eats a zero, someone would know me how to add this zero when it happens this case?

I use it to show two decimal places:

number_format($calcula_duplicata, 2, '.', '');
  • I made in my localhost its exact code and the return was 140.10

  • Yes, I’ve noticed that, the problem is that in what generates the xml it eats this zero

  • I wanted something that identified the amount of decimals it has and if it equals 1 add a zero

  • But is it exactly the same code? Can you elaborate a [mcve]?

  • But this php code you put in the question already does this Nicholas.

Show 1 more comment
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.