note 28423 deleted from function.is-float by didou

From: Date: Sun, 18 May 2003 10:14:36 +0000
Subject: note 28423 deleted from function.is-float by didou
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-48495@lists.php.net to get a copy of this message
Note Submitter: andy at home dot com ---- 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

« previous php.notes (#48495) next »