On Wed, 2002-01-30 at 08:16, liljim wrote: > Hi Bart, > > > I want to check the data from a form-field if it excists only of digits > > (0-9) and nothing else. > > > > How do I use the ereg()-function for this? > > Well, I prefer the preg_functions > > if (!preg_match("/^[0-9]{10}$/", $string)) { > // contains stuff other than numbers, or is less than 10 digits in length. > } > > You could also just use is_int() > http://www.php.net/manual/en/function.is-int.php > and strlen() > http://www.php.net/manual/en/function.strlen.php
Just a small correction--you should use is_numeric(), not is_int(); form fields are always presented as strings. Torben -- Torben Wilson <[EMAIL PROTECTED]> http://www.thebuttlesschaps.com http://www.hybrid17.com http://www.inflatableeye.com +1.604.709.0506 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]