<?php
// телефонный номер
//регулярка https://r...content-available-to-author-only...1.com/r/qF7vT8/3
$regExp = "/^(\+ *7| *8)( *\(*\)* *-* *\d){10}$/m";
$correctNumbers = [
'84951234567', '+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' /* нет + */
];
foreach($correctNumbers as $number){
echo "{$number}\n";
}
PD9waHAKCi8vINGC0LXQu9C10YTQvtC90L3Ri9C5INC90L7QvNC10YAKLy/RgNC10LPRg9C70Y/RgNC60LAgaHR0cHM6Ly9yLi4uY29udGVudC1hdmFpbGFibGUtdG8tYXV0aG9yLW9ubHkuLi4xLmNvbS9yL3FGN3ZUOC8zCgokcmVnRXhwID0gIi9eKFwrICo3fCAqOCkoICpcKCpcKSogKi0qICpcZCl7MTB9JC9tIjsKJGNvcnJlY3ROdW1iZXJzID0gWyAKICAnODQ5NTEyMzQ1NjcnLCAgJys3NDk1MTIzNDU2NycsICc4LTQ5NS0xLTIzNC01NjcnLCAKICAnIDggKDgxMjIpIDU2LTU2LTU2JywgJzgtOTExLTEyMzQ1NjcnLCAnOCAoOTExKSAxMiAzNDUgNjcnLCAKICAnOC05MTEgMTIgMzQ1IDY3JywgJzggKDkxMSkgLSAxMjMgLSA0NSAtIDY3JywgJysgNyA5OTkgMTIzIDQ1NjcnLCAKICAnOCAoIDk5OSApIDEyMzQ1NjcnLCAnOCA5OTkgMTIzIDQ1NjcnCl07CgokaW5jb3JyZWN0TnVtYmVycyA9IFsKICAnMDInLCAnODQ5NTEyMzQ1Njcg0L/QvtC30LLQsNG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