<?php
$regexp= "/^\\s*(8|([+]\\W*7))(\\W*\d){10}$/ui";
$numbers = [ // Правильные:
'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',
// Неправильные:
'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 ($numbers as $number)
{
{
echo "{$number} - верный номер\n";
}
else
{
echo "{$number} - неверный номер\n";
}
}
PD9waHAKCmVycm9yX3JlcG9ydGluZygtMSk7CiRyZWdleHA9ICIvXlxccyooOHwoWytdXFxXKjcpKShcXFcqXGQpezEwfSQvdWkiOwoKJG51bWJlcnMgPSBbIC8vINCf0YDQsNCy0LjQu9GM0L3Ri9C1OgogICc4NDk1MTIzNDU2NycsICAnKzc0OTUxMjM0NTY3JywgJzgtNDk1LTEtMjM0LTU2NycsIAogICcgOCAoODEyMikgNTYtNTYtNTYnLCAnOC05MTEtMTIzNDU2NycsICc4ICg5MTEpIDEyIDM0NSA2NycsIAogICc4LTkxMSAxMiAzNDUgNjcnLCAnOCAoOTExKSAtIDEyMyAtIDQ1IC0gNjcnLCAnKyA3IDk5OSAxMjMgNDU2NycsIAogICc4ICggOTk5ICkgMTIzNDU2NycsICc4IDk5OSAxMjMgNDU2NycsCi8vINCd0LXQv9GA0LDQstC40LvRjNC90YvQtTogCiAgJzAyJywgJzg0OTUxMjM0NTY3INC/0L7Qt9Cy0LDRgtGMINC70Y7RgdGOJywgJzg0OTUxMjM0NScsICc4NDk1MTIzNDU2NzgnLCAKICAnOCAoNDA5KSAxMjMtMTIzLTEyMycsICc3OTAwMTIzNDY3JywgJzUwMDUwMDUwMDEnLCAnOD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