- preg_match: documentation ( source)
- round: documentation ( source)
<?php
$float = array(
12.5,
12.000000001,
12.00000,
12,
12.41757445,
12.071774
);
foreach ($float as $i) {
if (false === preg_match('/\d+.[^1-9]+/', $i)) {
echo $i . PHP_EOL;
echo round($i) . " match" . PHP_EOL;
}
}