How can I cut unnecessary zeros at the end of a floating point value in PHP, like the following for example:
3.0 --> 3
12.56300 --> 12.563
etc.
You can just use (double) or (float) without (string)
echo (float)$input;
One easy way I found to do so is the following:
$output = (double) (string) $input;
number_format($number, number of digits);
for example
echo number_format(2.222222, 2); //2.22