note 28423 added to function.is-float
| From: | andy at rack1 dot php dot net | Date: | Mon, 13 Jan 2003 00:00:48 +0000 |
| Subject: | note 28423 added to function.is-float | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-42031@lists.php.net to get a copy of this message | ||
Ive been trying to get a price validation working with the is_float function but as far as i know it
wont work with a string input, so heres one i made which seems to do the trick.
function check_valid_price($num)
{
if (!(eregi('^[1-9]{1}[0-9]{0,2}$',$num)) &&
(!(eregi('^[0-9]{1}[0-9]{0,2}[.]{1}[0-9]{2}$',$num))))
{
return false;
}
else return true;
}
it accepts numbers like 1, 1.20, 0.99, but not 1.1, 1.111, 1.1., .20
--
http://www.php.net/manual/en/function.is-float.php
http://master.php.net/manage/user-notes.php?action=edit+28423
http://master.php.net/manage/user-notes.php?action=delete+28423
http://master.php.net/manage/user-notes.php?action=reject+28423