fork(2) download
  1. <?php
  2. function truncate($val, $f = "0") {
  3. if(($p = strpos($val, '.')) !== false) {
  4. $val = floatval(substr($val, 0, $p + 1 + $f));
  5. }
  6. return $val;
  7. }
  8. echo truncate(6.3285714285714, 2);
  9.  
  10. //https://pt.stackoverflow.com/q/317767/101
Success #stdin #stdout 0.03s 23576KB
stdin
Standard input is empty
stdout
6.32