Formatting does not work

Asked

Viewed 49 times

2

I am using this formatting so that the total returns me the correct value. But this line returns me without the pennies. The value has to return for example: 23.99 and is returning 23.00.

How to solve ?

$total = number_format($total,2, ',' , '.');
echo '<tr>
     <td colspan="5">TOTAL</td>
     <td><hr>  '.$total.'  </td>
     </tr>';
  • The $total has that content ? If it’s a matter of decimal being a , then is duplicate of many others that already have here on the site.

  • This is the total content: $total += number_format ($line["Unit"] * $Qtd, 2, ',' , '.');

  • Also include the code before this one. What you’ve posted so far has no way of knowing the problem.

  • Put a var_dump($total); exit; before this code and see if $total really has decimal part.

1 answer

0

If it’s just a mask question. If the value is being treated correctly (decimal or double) use the one from jquery;

Tem que colocar a referencia para :

jquery.maskMoney.min.js

$("#valor").maskMoney({
    prefix: "R$:",
    decimal: ",",
    thousands: "."
});

HTML:

<input class="form-control" type="text" id="valor"  value="0" />
  • I understand that your intention was to help. But the question regarding php.

Browser other questions tagged

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