fork(13) download
  1. <?php
  2. function convert($number)
  3. {
  4. $matches = Array();
  5. if (preg_match('/(\d+(?:\.\d+)?)E(-?\d+)/i', $number, $matches)) {
  6. $number = (float)$matches[1] * pow(10, (int)$matches[2]);
  7. }
  8.  
  9. return $number;
  10. }
  11.  
  12. var_dump(convert("9.018E-14"));
  13. var_dump(convert("9.018E-13"));
  14. var_dump(convert("901.8E-14"));
  15. var_dump(convert("901.8E-13"));
  16. var_dump(convert("901.8"));
  17. ?>
Success #stdin #stdout 0.01s 20520KB
stdin
Standard input is empty
stdout
float(9.018E-14)
float(9.018E-13)
float(9.018E-12)
float(9.018E-11)
string(5) "901.8"