Re: [PHP] ereg-digits only...

2002-02-12 Thread val petruchek

if ((int($string)==($string))  ($string0)) {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) [EMAIL PROTECTED]; Php-General (E-mail)
[EMAIL PROTECTED]
Sent: Tuesday, February 12, 2002 1:04 PM
Subject: [PHP] ereg-digits only...



 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



 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php






-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] ereg-digits only...

2002-02-12 Thread * RzE:

 if ((int($string)==($string))  ($string0)) {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 non-digit characters...);
}

-- 

* RzE:


-- 
-- Renze Munnik
-- DataLink BV
--
-- E: [EMAIL PROTECTED]
-- W: +31 23 5326162
-- F: +31 23 5322144
-- M: +31 6 21811143
--
-- Stationsplein 82
-- 2011 LM  HAARLEM
-- Netherlands
--
-- http://www.datalink.nl
-- 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] ereg-digits only...

2002-02-12 Thread Daniel Kushner

That wouldn't work! 
1) You meant to write: if (((int)$string==$string)  ($string0))

2) (int)'5a' == 5, so this formula would result is 5a == 5!

--Daniel


 -Original Message-
 From: val petruchek [mailto:[EMAIL PROTECTED]]
 Sent: Tuesday, February 12, 2002 6:22 AM
 To: [EMAIL PROTECTED]
 Cc: PHP
 Subject: Re: [PHP] ereg-digits only...
 
 
 if ((int($string)==($string))  ($string0)) {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) [EMAIL PROTECTED]; Php-General (E-mail)
 [EMAIL PROTECTED]
 Sent: Tuesday, February 12, 2002 1:04 PM
 Subject: [PHP] ereg-digits only...
 
 
 
  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
 
 
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 
 
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] ereg-digits only...

2002-02-12 Thread val petruchek

as a said before i'm not sure; my idea was to use type casting instead of
eregi;
anyone can develop it into smart solution; i am out of time now for this
developing
so can suggest idea only

Valentin Petruchek (aki Zliy Pes)
*** cUT THE BEGINNING ***
http://zliypes.com.ua
mailto:[EMAIL PROTECTED]
- 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 wouldn't work!
 1) You meant to write: if (((int)$string==$string)  ($string0))

 2) (int)'5a' == 5, so this formula would result is 5a == 5!

 --Daniel


  -Original Message-
  From: val petruchek [mailto:[EMAIL PROTECTED]]
  Sent: Tuesday, February 12, 2002 6:22 AM
  To: [EMAIL PROTECTED]
  Cc: PHP
  Subject: Re: [PHP] ereg-digits only...
 
 
  if ((int($string)==($string))  ($string0)) {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) [EMAIL PROTECTED]; Php-General
(E-mail)
  [EMAIL PROTECTED]
  Sent: Tuesday, February 12, 2002 1:04 PM
  Subject: [PHP] ereg-digits only...
 
 
  
   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
  
  
  
   --
   PHP General Mailing List (http://www.php.net/)
   To unsubscribe, visit: http://www.php.net/unsub.php
  
  
 
 
 
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] ereg-digits only...

2002-02-12 Thread Lars Torben Wilson

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 [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, visit: http://www.php.net/unsub.php