Well, first, lets have a little lesson. The first three are actually pretty simple, and for them I'm going to use preg_match.
For 6 digits only:
if (preg_match("/([0-9]{6})$/", $variable)) {
// Its 6 digits
}
Basically, what we need to look at it /([0-9]{6})$/ .. first, the front slashes (/) just mark the beginning and the end of the expression. the ^ says "beginning of the variable". [0-9] says match only digits, and {6} tells it to match it exactly 6 times. The final $ tells it to "match the end of the variable". So to get the second one, we just replace the 6 with a 7:
if (preg_match("/([0-9]{7})$/", $variable)) {
// Its 7 digits
}
And for the third, we use a range {8,10}
if (preg_match("/([0-9]{8,10})$/", $variable)) {
// Its 7 digits
}
for these:
255 or less alphanumeric charcters
255 or less letters
It would be better to do:
if (strlen($variable) < 256) {
// It's 255 or less
}
and if you need just letters
if (preg_match("/[a-zA-Z]/", $variable)) {
// Only characters
}
The final email regular expression is widely documented, look at www.zend.com in the code snippets or at the manual page for preg_match or ereg. Hope that helps!
Chris King