06-07-2008, 12:11 PM
|
#2 (permalink)
|
|
Moderateur
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
|
You could look to use strspn or strcspn rather than using the more 'powerful' (for want of a better term) regular expression functions.
PHP Code:
$test = '+44-1234-5678';
if (strcspn($test, '1234567890+-')) { echo 'Test contains one or more invalid characters'; } else { echo 'Test is nice and only contains digits, plus or dash'; }
|
|
|
|