Re: ereg-digits only...
| From: | Lars Torben Wilson | Date: | Tue, 12 Feb 2002 19:56:41 +0000 |
| Subject: | Re: ereg-digits only... | ||
| References: | 1 | Groups: | php.db php.general |
| Request: | Send a blank email to php-db+get-16869@lists.php.net to get a copy of this message | ||
On Tue, 2002-02-12 at 03:04, B. Verbeek wrote:
>
> How do I check a string for it to only contain numbers?
>
> >>
>
> if(!ereg("([0-9]+)",$string)){
>
> print "It contains characters other than numbers";
>
> }else{
>
> print "Only numbers";
>
> }
>
> <<
>
> Can anyone give some feedback...
>
> regards,
> Bart
Sure, try is_numeric():
http://www.php.net/is_numeric
Hope this helps,
Torben
--
Torben Wilson <torben@php.net>
http://www.thebuttlesschaps.com
http://www.hybrid17.com
http://www.inflatableeye.com
+1.604.709.0506