Re: [PHP] Removing non-numbers

2005-02-15 Thread Richard Lynch
Ben Miller wrote:
> OK - easy one here, I know.  Having troubles removing anything that is not
> a
> number from user input.  According to manual, [!] is supposed to mean set
> of
> non-matching optional characters.  Tried

! means that, but only in a completely different context from what you are
using...

>   $var = ereg_replace("[!0-9]","",$var);

$var = ereg_replace("[^0-9]", "", $var);

> and it removes the numbers, but so does
>
>   $var = ereg_replace("[0-9]","",$var);

What you had was stripping OUT the digits.  Plus taking out "!" in the
first one.

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] Removing non-numbers

2005-02-14 Thread Greg Donald
On Mon, 14 Feb 2005 18:54:03 -0700, Ben Miller <[EMAIL PROTECTED]> wrote:
> OK - easy one here, I know.  Having troubles removing anything that is not a
> number from user input.  According to manual, [!] is supposed to mean set of
> non-matching optional characters.

$var = preg_replace( '/[^\d]/', '', $var );


-- 
Greg Donald
Zend Certified Engineer
http://destiney.com/

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



[PHP] Removing non-numbers

2005-02-14 Thread Ben Miller
OK - easy one here, I know.  Having troubles removing anything that is not a
number from user input.  According to manual, [!] is supposed to mean set of
non-matching optional characters.  Tried

$var = ereg_replace("[!0-9]","",$var);

and it removes the numbers, but so does

$var = ereg_replace("[0-9]","",$var);

Any quick fix is greatly appreciated.  Would be great to not have to list
every possible character a user might enter between the [ and the ].
Doesn't matter how may times and how big of letters I use to say "enter
numbers only", people still enter non-numbers.

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