<?php
// Правильные:
$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'
];
$regexp = "/\\s?(8|[+]\\s?7)([-]?[)]?[(]?\\s?\\d[-]?[)]?[(]?\\s?){10}/";
foreach($correctNumbers as $number){
$match = [];
echo "Строка $number\n";
echo "Найден номер $number\n\n";
}
else {
echo "Номер не найден\n\n";
}
}
PD9waHAKCi8vINCf0YDQsNCy0LjQu9GM0L3Ri9C1OgokY29ycmVjdE51bWJlcnMgPSBbCic4NDk1MTIzNDU2NycsICAnKzc0OTUxMjM0NTY3JywgJzgtNDk1LTEtMjM0LTU2NycsCicgOCAoODEyMikgNTYtNTYtNTYnLCAnOC05MTEtMTIzNDU2NycsICc4ICg5MTEpIDEyIDM0NSA2NycsCic4LTkxMSAxMiAzNDUgNjcnLCAnOCAoOTExKSAtIDEyMyAtIDQ1IC0gNjcnLCAnKyA3IDk5OSAxMjMgNDU2NycsCic4ICggOTk5ICkgMTIzNDU2NycsICc4IDk5OSAxMjMgNDU2NycKXTsKCgoKJHJlZ2V4cCA9ICIvXFxzPyg4fFsrXVxccz83KShbLV0/WyldP1soXT9cXHM/XFxkWy1dP1spXT9bKF0/XFxzPyl7MTB9LyI7Cgpmb3JlYWNoKCRjb3JyZWN0TnVtYmVycyBhcyAkbnVtYmVyKXsKICAgICRtYXRjaCA9IFtdOwogICAgZWNobyAi0KHRgtGA0L7QutCwICRudW1iZXJcbiI7CiAgICBpZihwcmVnX21hdGNoKCRyZWdleHAsICRudW1iZXIsICRtYXRjaCkpewogICAgICAgIGVjaG8gItCd0LDQudC00LXQvSDQvdC+0LzQtdGAICRudW1iZXJcblxuIjsKICAgIH0KICAgIGVsc2UgewogICAgICAgIGVjaG8gItCd0L7QvNC10YAg0L3QtSDQvdCw0LnQtNC10L1cblxuIjsKICAgIH0KfQ==