Can someone explain me what is wrong with this AFTER line of code.
BEFORE (EXAMPLE - HOW TO USE):
"value" => "27.50" //enforce the use of strings
AFTER:
"value" => "round($_SESSION["Payment_Amount"], 2)" //Think of that Payment_Amount is 198,99 in session.
An explanation why it goes wrong would be very appreciated.
I would suggest using a formatting function like sprintf
or number_format
instead of round
.
"value" => sprintf('%0.2f', $_SESSION["Payment_Amount"])
For two reasons:
round
won't show them if there happen to be trailing zeros, because it returns a float, and floats don't show trailing zeros when they're converted to strings.