- var_dump: documentation ( source)
- preg_match: documentation ( source)
- number_format: documentation ( source)
<?php
function float_strval($fltValue)
{
$strValue = (string)$fltValue;
if (preg_match("/E([\+\-])(\d+)$/", $strValue, $captures)) {
if ($captures[1] === '-') {
$strValue = number_format($fltValue, $captures[2], '.', '');
} else {
$strValue = number_format($fltValue, 0, '.', '');
}
}
return [$fltValue, $strValue];
}
var_dump(float_strval(0.00000021));
var_dump(float_strval(1209381092380198230.123));