1. Use "decimal + 0".
<?php echo '100.00' + 0 ." "; echo '100.01000' + 0 ." "; echo '100.10000' + 0 ." "; ?>
2. Use "floatval (decimal)".
<?php echo floatval('100.00')." "; echo floatval('100.01000')." "; echo floatval('100.10000')." "; ?>
3. Use "rtrim(rtrim(decimal,'0'),'.')".
<?php echo rtrim(rtrim('100.00', '0'), '.')." "; echo rtrim(rtrim('100.01000', '0'), '.')." "; echo rtrim(rtrim('100.10000', '0'), '.')." "; ?>
4. Use "preg_replace('/[.]$/','', preg_replace('/0+$/','', decimal)".
Regular expression description: /0+$/ removes the extra 0 at the end /[.]$/ remove the trailing . echo preg_replace('/[.]$/', '', preg_replace('/0+$/', '', '100.00'))." "; echo preg_replace('/[.]$/', '', preg_replace('/0+$/', '', '100.1000'))." "; echo preg_replace('/[.]$/', '', preg_replace('/0+$/', '', '100.010203000'))." "; ?>
The above is how to remove excess zeros after the decimal point in PHP. I hope it will be helpful to everyone. More PHP learning guide: source code network