Re: [PHP] ereg checking if its only numbers

2001-10-05 Thread Rasmus Lerdorf

http://php.net/is_numeric

On Fri, 5 Oct 2001, Chris Aitken wrote:


 Ive been playing around with ereg for about half an hour and having no joy
 because I dont really understand the medhod behind it and how it all works.
 But what im trying to do is check to see if a 9 digit string is all numbers
 and nothing else

 $string1 = 123456789
 $string2 = 123456abc


 how would I check either string with an IF statement and make it continue
 on string 1 (ie, all numbers) and error on string 2 (not all numbers).


 Any suggestions ?



 Thanks


 Chris

 --
  Chris Aitken - Administration/Database Designer - IDEAL Internet
   email: [EMAIL PROTECTED]  phone: +61 2 4628   fax: +61 2 4628 8890
   __-__
 It is said that if you line up all the cars in the world end to end,
   some moron in a rotary will still to try and pass them





-- 
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]




Re: [PHP] ereg checking if its only numbers

2001-10-05 Thread _lallous

That's not regexps Rasmus! :)
I always see you referring us the the manual! sometimes you refer to a
function i never say in my life! ;)

Rasmus Lerdorf [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 http://php.net/is_numeric

 On Fri, 5 Oct 2001, Chris Aitken wrote:

 
  Ive been playing around with ereg for about half an hour and having no
joy
  because I dont really understand the medhod behind it and how it all
works.
  But what im trying to do is check to see if a 9 digit string is all
numbers
  and nothing else
 
  $string1 = 123456789
  $string2 = 123456abc
 
 
  how would I check either string with an IF statement and make it
continue
  on string 1 (ie, all numbers) and error on string 2 (not all numbers).
 
 
  Any suggestions ?
 
 
 
  Thanks
 
 
  Chris
 
  --
   Chris Aitken - Administration/Database Designer - IDEAL Internet
email: [EMAIL PROTECTED]  phone: +61 2 4628   fax: +61 2 4628
8890
__-__
  It is said that if you line up all the cars in the world end to end,
some moron in a rotary will still to try and pass them
 
 
 




-- 
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]




RE: [PHP] ereg checking if its only numbers

2001-10-04 Thread Jack Dempsey

if(!preg_match(/^\d+$/,$string){
echo $string has something other than a number;
}

-Original Message-
From: Chris Aitken [mailto:[EMAIL PROTECTED]]
Sent: Thursday, October 04, 2001 9:34 PM
To: PHP General Mailing List
Subject: [PHP] ereg checking if its only numbers



Ive been playing around with ereg for about half an hour and having no joy
because I dont really understand the medhod behind it and how it all works.
But what im trying to do is check to see if a 9 digit string is all numbers
and nothing else

$string1 = 123456789
$string2 = 123456abc


how would I check either string with an IF statement and make it continue
on string 1 (ie, all numbers) and error on string 2 (not all numbers).


Any suggestions ?



Thanks


Chris

--
 Chris Aitken - Administration/Database Designer - IDEAL Internet
  email: [EMAIL PROTECTED]  phone: +61 2 4628   fax: +61 2 4628 8890
  __-__
It is said that if you line up all the cars in the world end to end,
  some moron in a rotary will still to try and pass them


--
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]



-- 
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]




RE: [PHP] ereg checking if its only numbers

2001-10-04 Thread Maxim Maletsky \(PHPBeginner.com\)

With ereg it could be:

 if(ereg(^[^[:digit:]]+$))
echo 'something else came through';

Untested though ... 

Maxim Maletsky
www.PHPBeginner.com



 -Original Message-
 From: Jack Dempsey [mailto:[EMAIL PROTECTED]] 
 Sent: venerdì 5 ottobre 2001 3.42
 To: Chris Aitken; PHP General Mailing List
 Subject: RE: [PHP] ereg checking if its only numbers
 
 
 if(!preg_match(/^\d+$/,$string){
   echo $string has something other than a number;
 }
 
 -Original Message-
 From: Chris Aitken [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, October 04, 2001 9:34 PM
 To: PHP General Mailing List
 Subject: [PHP] ereg checking if its only numbers
 
 
 
 Ive been playing around with ereg for about half an hour and 
 having no joy because I dont really understand the medhod 
 behind it and how it all works. But what im trying to do is 
 check to see if a 9 digit string is all numbers and nothing else
 
 $string1 = 123456789
 $string2 = 123456abc
 
 
 how would I check either string with an IF statement and make 
 it continue on string 1 (ie, all numbers) and error on string 
 2 (not all numbers).
 
 
 Any suggestions ?
 
 
 
 Thanks
 
 
 Chris
 
 --
  Chris Aitken - Administration/Database Designer - IDEAL Internet
   email: [EMAIL PROTECTED]  phone: +61 2 4628   fax: +61 
 2 4628 8890
   __-__
 It is said that if you line up all the cars in the world 
 end to end,
   some moron in a rotary will still to try and pass them
 
 
 --
 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]
 
 
 
 -- 
 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]
 
 


--
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]




Re: [PHP] ereg checking if its only numbers

2001-10-04 Thread Evan

try:

?
if(ereg([0-9]{9}, $string)){
echo Success, 9 numbers!;
} else {
echo Failure, not 9 numbers.;
}
?

There is a great book on regular expressions by o'reily.

Evan

*** REPLY SEPARATOR  ***

On 10/5/01 at 11:33 AM Chris Aitken wrote:

Ive been playing around with ereg for about half an hour and having no
joy
because I dont really understand the medhod behind it and how it all
works.
But what im trying to do is check to see if a 9 digit string is all
numbers
and nothing else

$string1 = 123456789
$string2 = 123456abc


how would I check either string with an IF statement and make it continue
on string 1 (ie, all numbers) and error on string 2 (not all numbers).


Any suggestions ?



Thanks


Chris

--
 Chris Aitken - Administration/Database Designer - IDEAL Internet
  email: [EMAIL PROTECTED]  phone: +61 2 4628   fax: +61 2 4628 8890
  __-__
It is said that if you line up all the cars in the world end to end,
  some moron in a rotary will still to try and pass them


--
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]

¾


--
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]