fork(26) download
  1. <?php
  2.  
  3.  
  4. function strip_zeros($number) {
  5. return preg_replace("/\.?0+$/", "", $number);
  6. }
  7.  
  8. echo strip_zeros(3.0) , PHP_EOL;
  9. echo strip_zeros(3.1) , PHP_EOL;
  10. echo strip_zeros(10000001.0) , PHP_EOL;
  11. echo strip_zeros(10000001.1) , PHP_EOL;
Success #stdin #stdout 0.01s 82624KB
stdin
Standard input is empty
stdout
3
3.1
10000001
10000001.1