note 106440 modified in function.intval by danbrown
| From: | danbrown@php.net | Date: | Tue, 15 Nov 2011 16:40:49 +0000 |
| Subject: | note 106440 modified in function.intval by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-184489@lists.php.net to get a copy of this message | ||
inval work well with numbers except the kind:
intval("10.2e+2")
which gives 10
the trick around is to use the following function:
<?php
function smart_val($string) {
eval("\$number=$string;");
return $number;
}
?>
Doing <?php echo smart_val("10.2e+2"); ?>
gives: 1020
--was--
inval work well with numbers except the kind:
intval("10.2e+2")
which gives 10
the trick around is to use the following function:
function smart_val($string) {
eval("\$number=$string;");
return $number;
}
Doing smart_val("10.2e+2")
gives 1020
http://php.net/manual/en/function.intval.php