I solved it slightly differently, but big thanks to you Kirk anyway.
Here's the function:
Function validphonenr($num="")
validphonenr(): returns TRUE or FALSE depedning on criteria
{
if ($num == "")
{
the num can be empty
return TRUE;
}
## if the num is not empty then check it
$regex = "^(\+|[0-9])([0-9[:space:]-])+$";
if (ereg( $regex, $num ) )
{
return TRUE;
}
else
{
return FALSE;
}
}
This returns true on:
+440708870654
+44 0708-870-654
0208-07872521
0208-078 72 5 21
020807872521
etc.
But not:
44+0708870654
+44*0708-870-654
A0654054064064
0044 (0) 207 54 654 646
mob: 020807872521
etc.
However, the Regex doesn't control double whitespace.
I know that I can put [:space:]{1}.
The means that: "020 8454654" will fail.
But wouldn't then also "020 8454 654" also fail? I'll give it a try.