> From: Jason Wong [mailto:[EMAIL PROTECTED] > > On Sunday 08 June 2003 16:22, Philip J. Newman wrote: > > I would liek to check for 0-9 and . charactors i'm using ... > > > > $email = "60.00"; > > > > if eregi("^[0-9.])?$",$email) { > > > > echo"valid"; > > > > } else { > > > > echo"not valid"; > > > > } > > > > Its not working well. umm ... help ... > > eregi("^([0-9.])*$", $string) > > will match: > an empty string > a string containing only 0-9 and periods > > It is better for you to learn the preg_*() functions instead of the > ereg*() > ones.
FYI, that code will also allow a string such as "99.4.3....223...04..." If that's not desirable, you could look into using the is_float() or is_numeric() functions, or a regex such as: if(preg_match('/^[0-9]*\.?[0-9]+$/',$string)) { echo "good"; } else { echo "bad"; } That will allow text/numbers with or without a period. ---John W. Holmes... Amazon Wishlist: http://www.amazon.com/o/registry/3BEXC84AB3A5E PHP Architect - A monthly magazine for PHP Professionals. Get your copy today. http://www.phparch.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php