1 case 3:
2 $rgx = "/^[A-Z0-9._%+-]+@[A-Z0-9.-]+.[A-Z]{2,4}$/i";
3 break;
4
5 case 2:
6 //read below
7 $rgx = "/[^A-Za-z0-9]+/";
8 break;
9
10 case 1:
11 //read below
12 $rgx = "/[^A-Za-z0-9]+/";
13 break;
14
15 case 0:
16 //if characters are NOT normal
17 $rgx = "/[^A-Za-z0-9]+/";
18 break;
19
20 default:
21 echo "???";
22 die("$unit ?");
23 break;
24}
25
26$n = preg_match($rgx, $unit, $matches);
27if ( ($idx == 0) || ($idx == 1) || ($idx == 2) ){
28 if ($n) {
29 echo "Bad Characters in $unit; Alphanumeric only";
30 }
31} else {
32 if ($n == 0) {
33 echo "Incorrect Format in $unit; Enter Valid Info";
34 }
35}