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
ECTED]
- Original Message -
From: "Daniel Kushner" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Cc: "PHP" <[EMAIL PROTECTED]>
Sent: Tuesday, February 12, 2002 4:00 PM
Subject: RE: [PHP] ereg-digits only...
> That would
ruary 12, 2002 6:22 AM
> To: [EMAIL PROTECTED]
> Cc: PHP
> Subject: Re: [PHP] ereg-digits only...
>
>
> if ((int($string)==($string)) && ($string>0)) {then positive integer}
>
> not sure exactly, but try
>
> Valentin Petruchek (aki Zliy Pes)
&
> if ((int($string)==($string)) && ($string>0)) {then positive integer}
>
> not sure exactly, but try
Why not use the RE's? I usually use preg_* so I'll give the example
using these...
if (preg_match ("/^\d+$/", $string)) {
print ("Yep... Only digits.");
} else {
prnt ("Noop! There are no
if ((int($string)==($string)) && ($string>0)) {then positive integer}
not sure exactly, but try
Valentin Petruchek (aki Zliy Pes)
*** Cut the beginning ***
http://zliypes.com.ua
mailto:[EMAIL PROTECTED]
- Original Message -
From: "B. Verbeek" <[EMAIL PROTECTED]>
To: "Php-Db-Help (E-mail)
5 matches
Mail list logo