<?php
function numCheck($numArray) {
foreach ($numArray as $id => $number) {
$regexp = "/^\ ?((\+\ ?7)|8)\ ?(([\ \-\(\ ]+)?\d[\ \)]?){10}$/";
echo "{$number} - корректный номер телефона \n";
} else {
echo "{$number} - телефон указан неверно \n";
}
}
}
$correctNumbers = [
'8 ( 495 ) 1 - 2 - 3 - 4 - 5 - 6 - 7'
];
$incorrectNumbers = [
'8 911 415 (16) (13)', '8 (((((((((((((((1938(((((2)((((21(((((21(((2', '8(((((((-------((((( ( --- ((((9(((1(((1)3------4----------5-----------6-----------7----((((8--------9)'
];
numCheck($correctNumbers);
numCheck($incorrectNumbers);
PD9waHAKCmVycm9yX3JlcG9ydGluZygtMSk7CgpmdW5jdGlvbiBudW1DaGVjaygkbnVtQXJyYXkpIHsKCWZvcmVhY2ggKCRudW1BcnJheSBhcyAkaWQgPT4gJG51bWJlcikgewoJCSRyZWdleHAgPSAiL15cID8oKFwrXCA/Nyl8OClcID8oKFtcIFwtXChcIF0rKT9cZFtcIFwpXT8pezEwfSQvIjsKCQlpZiAocHJlZ19tYXRjaCgkcmVnZXhwLCAkbnVtYmVyKSkgewoJCQllY2hvICJ7JG51bWJlcn0gLSDQutC+0YDRgNC10LrRgtC90YvQuSDQvdC+0LzQtdGAINGC0LXQu9C10YTQvtC90LAgXG4iOwoJCX0gZWxzZSB7CgkJCWVjaG8gInskbnVtYmVyfSAtINGC0LXQu9C10YTQvtC9INGD0LrQsNC30LDQvSDQvdC10LLQtdGA0L3QviBcbiI7CgkJfQoJfQp9CiRjb3JyZWN0TnVtYmVycyA9IFsgCiAgJzggKCA0OTUgKSAxIC0gMiAtIDMgLSA0IC0gNSAtIDYgLSA3JwpdOwokaW5jb3JyZWN0TnVtYmVycyA9IFsKICAnOCA5MTEgNDE1ICgxNikgKDEzKScsICc4ICgoKCgoKCgoKCgoKCgoKDE5MzgoKCgoKDIpKCgoKDIxKCgoKCgyMSgoKDInLCAnOCgoKCgoKCgtLS0tLS0tKCgoKCggKCAtLS0gKCgoKDkoKCgxKCgoMSkzLS0tLS0tNC0tLS0tLS0tLS01LS0tLS0tLS0tLS02LS0tLS0tLS0tLS03LS0tLSgoKCg4LS0tLS0tLS05KScgCl07Cm51bUNoZWNrKCRjb3JyZWN0TnVtYmVycyk7Cm51bUNoZWNrKCRpbmNvcnJlY3ROdW1iZXJzKTs=