fork download
  1. <?php
  2.  
  3. function cleanPrice($pris) {
  4. $last = substr($pris, strlen($pris)-1);
  5. switch($last) {
  6. case "k": $scale = 1000; break;
  7. case "m": $scale = 1000000; break;
  8. default: $scale = 1;
  9. }
  10. return preg_replace('/[^-0-9.]/', '', $pris) * $scale;
  11. }
  12.  
  13. echo cleanPrice('1.4m');
Success #stdin #stdout 0.02s 20568KB
stdin
Standard input is empty
stdout
1400000