<?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/RgNC60LAgaHR0cHM6Ly9yLi4uY29udGVudC1hdmFpbGFibGUtdG8tYXV0aG9yLW9ubHkuLi4xLmNvbS9yL3FGN3ZUOC8zCgokcmVnRXhwID0gIi9eKFwrICo3fCAqOCkoWyAoKS1dKlxkKXsxMH0kL20iOwokY29ycmVjdE51bWJlcnMgPSBbIAogICc4NDk1MTIzNDU2NycsICAnKzc0OTUxMjM0NTY3JywgJzgtNDk1LTEtMjM0LTU2NycsIAogICcgOCAoODEyMikgNTYtNTYtNTYnLCAnOC05MTEtMTIzNDU2NycsICc4ICg5MTEpIDEyIDM0NSA2NycsIAogICc4LTkxMSAxMiAzNDUgNjcnLCAnOCAoOTExKSAtIDEyMyAtIDQ1IC0gNjcnLCAnKyA3IDk5OSAxMjMgNDU2NycsIAogICc4ICggOTk5ICkgMTIzNDU2NycsICc4IDk5OSAxMjMgNDU2NycKXTsKCiRpbmNvcnJlY3ROdW1iZXJzID0gWwogICcwMicsICc4NDk1MTIzNDU2NyDQv9C+0LfQstCw0YLRjCDQu9GO0YHRjicsICc4NDk1MTI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