php, add trailing zeros if the number is integer
Use the number_format
function. If you don't want comma separators, set all four parameters of the function like so (the thousands separator is the fourth parameter):
$number = number_format(1234, 2, '.', '');
Yup, using https://www.php.net/manual/en/function.number-format.php function like this:
$a = 123;
$answer = number_format($a,"2");
echo $answer;
Use sprintf("%0.2f",$a);
. docs