<?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', '+74951234567', '8-495-1-234-567',
' 8 (8122) 56-56-56', '8-911-1234567', '8 (911) 12 345 67',
'8-911 12 345 67', '8 (911) - 123 - 45 - 67', '+ 7 999 123 4567',
'8 ( 999 ) 1234567', '8 999 123 4567'
];
$incorrectNumbers = [
'02', '84951234567 позвать люсю', '849512345', '849512345678',
'8 (409) 123-123-123', '7900123467', '5005005001', '8888-8888-88',
'84951a234567', '8495123456a',
'+1 234 5678901', /* неверный код страны */
'+8 234 5678901', /* либо 8 либо +7 */
'7 234 5678901' /* нет + */
];
numCheck($correctNumbers);
numCheck($incorrectNumbers);
PD9waHAKCmVycm9yX3JlcG9ydGluZygtMSk7CgpmdW5jdGlvbiBudW1DaGVjaygkbnVtQXJyYXkpIHsKCWZvcmVhY2ggKCRudW1BcnJheSBhcyAkaWQgPT4gJG51bWJlcikgewoJCSRyZWdleHAgPSAiL15cID8oKFwrXCA/Nyl8OClcID8oKFtcIFwtXChcIF0rKT9cZFtcIFwpXT8pezEwfSQvIjsKCQlpZiAocHJlZ19tYXRjaCgkcmVnZXhwLCAkbnVtYmVyKSkgewoJCQllY2hvICJ7JG51bWJlcn0gLSDQutC+0YDRgNC10LrRgtC90YvQuSDQvdC+0LzQtdGAINGC0LXQu9C10YTQvtC90LAgXG4iOwoJCX0gZWxzZSB7CgkJCWVjaG8gInskbnVtYmVyfSAtINGC0LXQu9C10YTQvtC9INGD0LrQsNC30LDQvSDQvdC10LLQtdGA0L3QviBcbiI7CgkJfQoJfQp9CiRjb3JyZWN0TnVtYmVycyA9IFsgCiAgJzggKCA0OTUgKSAxIC0gMiAtIDMgLSA0IC0gNSAt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