You have a couple of problems.
1) 123456 is a 6-digit number, not a five digit number.
2) Your switch statement is useless. Under no circumstances is "123456" equal to preg_match('/\d{5}$/', "123456"). In fact, the only value for $x I can think of where $x == preg_match('/\d{5}$/',$x) is 0.
You may find this helpful:
$x = "123456";
echo preg_match('/^\d{6}$/',$x) . "<br>";
switch (preg_match('/^\d{6}$/',$x)) {
case 1:
$num = "3";
break;
default:
$num = "0";
}
echo $num . '<br>';