[PHP] is this correct? regular expressions

2003-03-25 Thread Jay Paulson
just trying to say if $phone isn't all numbers set it to all zeros.. so is that right? 
cause i can't seem to get it to work.

   if (!ereg(^[0-9]$,$phone)) {
$phone = 00;
   }

thanks!

Re: [PHP] is this correct? regular expressions

2003-03-25 Thread Ernest E Vogelsinger
At 23:22 25.03.2003, Jay Paulson said:
[snip]
just trying to say if $phone isn't all numbers set it to all zeros.. so is 
that right? cause i can't seem to get it to work.

   if (!ereg(^[0-9]$,$phone)) {
$phone = 00;
   }

thanks!
[snip] 

This is if $phone is anything else than a single digit. You need to add
either a plus or an asterisk after the closing bracket to denote multiple
instances of the character set:
  if (!ereg(^[0-9]*$,$phone)) {

You could also check if anything _not_ being a number exists within $phone:
  if (ereg([^0-9],$phone)) {



-- 
   O Ernest E. Vogelsinger
   (\)ICQ #13394035
^ http://www.vogelsinger.at/



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