Hi Bart,

> I want to check the data from a form-field if it excists only of digits
> (0-9) and nothing else.
> How do I use the ereg()-function for this?

Well, I prefer the preg_functions

if (!preg_match("/^[0-9]{10}$/", $string)) {
// contains stuff other than numbers, or is less than 10 digits in length.

You could also just use is_int()
and strlen()

>   >>  ereg("[0-9]",$cust_tel, $cust_tel);  <<
> It is also to turn it around but then the pattern will get larger because
> has to contain:
>  / "'.,-)(*&^%# a-z A-Z and so on...
> The field has to be 10 digits long and has to contain only digits!!!


If you just want digits, then where've those other patterns come from?  Do
you mean you want anything BUT numbers?

if (!preg_match("/^[^0-9]+$/", $string_without_numbers)) {
// string contains numbers

otherwise, please clarify.


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]

Reply via email to