<?php
'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 ( 909 ) 1234567',
'8 999 123 4567',
'8 952-58 -51 25-5',
'02',
'84951234567 позвать люсю',
'849512345',
'849512345678',
'8 (409) 123-123-123',
'7900123467',
'5005005001',
'8888-8888-88',
'84951a234567',
'8495123456a',
'+1 234 5678901',
'+8 234 5678901',
'7 234 5678901'
);
$regexp_control = '/(^([- \\(\\)]*\\+[- \\(\\)]*7)|^[- \\(\\)]*8)([- \\(\\)]*[0-9]){10}$/';
$regexp_replace = array('/^([- \\(\\)]*\\+[- \\(\\)]*7)/', '/[- \\(\\)]/'); $replacement = array('8', ''); $i = 0;
foreach ($lines as $number) {
$result[$i] = preg_replace($regexp_replace, $replacement, $number); echo "Nomer OK, formatirovanie idet, zapis #$i\n";
} else {
echo "Error! $i\n";
}
++$i;
}
PD9waHAKICRsaW5lcyA9IGFycmF5KAogICc4NDk1MTIzNDU2NycsCiAgJys3NDk1MTIzNDU2NycsCiAgJzgtNDk1LTEtMjM0LTU2NycsCiAgJzggKDgxMjIpIDU2LTU2LTU2JywKICAnIDgtOTExLTEyMzQ1NjcnLAogICc4ICg5MTEpIDEyIDM0NSA2NycsCiAgJzgtOTExIDEyIDM0NSA2NycsCiAgJzggKDkxMSkgLSAxMjMgLSA0NSAtIDY3JywKICAnKyA3IDk5OSAxMjMgNDU2NycsCiAgJzggKCA5MDkgKSAxMjM0NTY3JywKICAnOCA5OTkgMTIzIDQ1NjcnLAogICc4IDk1Mi01OCAtNTEgMjUtNScsCiAgJzAyJywKICAnODQ5NTEyMzQ1Njcg0L/QvtC30LLQsNGC0Ywg0LvRjtGB0Y4nLAogICc4NDk1MTIzNDUnLAogICc4NDk1MTIzNDU2NzgnLAogICc4ICg0MDkpIDEyMy0xMjMtMTIzJywKICAnNzkwMDEyMzQ2NycsCiAgJzUwMDUwMDUwMDEnLAogICc4ODg4LTg4ODgtODgnLAogICc4NDk1MWEyMzQ1NjcnLAogICc4NDk1MTIzNDU2YScsCiAgJysxIDIzNCA1Njc4OTAxJywKICAnKzggMjM0IDU2Nzg5MDEnLAogICc3IDIzNCA1Njc4OTAxJwogICk7CiAgJHJlZ2V4cF9jb250cm9sID0gJy8oXihbLSBcXChcXCldKlxcK1stIFxcKFxcKV0qNyl8XlstIFxcKFxcKV0qOCkoWy0gXFwoXFwpXSpbMC05XSl7MTB9JC8nOwogICRyZWdleHBfcmVwbGFjZSA9IGFycmF5KCcvXihbLSBcXChcXCldKlxcK1stIFxcKFxcKV0qNykvJywgJy9bLSBcXChcXCldLycpOwogICRyZXBsYWNlbWVudCA9IGFycmF5KCc4JywgJycpOwogICRyZXN1bHQgPSBhcnJheSgpOwogICRpID0gMDsKICBmb3JlYWNoICgkbGluZXMgYXMgJG51bWJlcikgewogIGlmIChwcmVnX21hdGNoKCRyZWdleHBfY29udHJvbCwgJG51bWJlcikpIHsKICAkcmVzdWx0WyRpXSA9IHByZWdfcmVwbGFjZSgkcmVnZXhwX3JlcGxhY2UsICRyZXBsYWNlbWVudCwgJG51bWJlcik7CiAgZWNobyAiTm9tZXIgT0ssIGZvcm1hdGlyb3ZhbmllIGlkZXQsIHphcGlzICMkaVxuIjsKICB9IGVsc2UgewogIGVjaG8gIkVycm9yISAkaVxuIjsKICB9CiAgKyskaTsKICB9CiAgdmFyX2R1bXAoJHJlc3VsdCk7
Nomer OK, formatirovanie idet, zapis #0
Nomer OK, formatirovanie idet, zapis #1
Nomer OK, formatirovanie idet, zapis #2
Nomer OK, formatirovanie idet, zapis #3
Nomer OK, formatirovanie idet, zapis #4
Nomer OK, formatirovanie idet, zapis #5
Nomer OK, formatirovanie idet, zapis #6
Nomer OK, formatirovanie idet, zapis #7
Nomer OK, formatirovanie idet, zapis #8
Nomer OK, formatirovanie idet, zapis #9
Nomer OK, formatirovanie idet, zapis #10
Nomer OK, formatirovanie idet, zapis #11
Error! 12
Error! 13
Error! 14
Error! 15
Error! 16
Error! 17
Error! 18
Error! 19
Error! 20
Error! 21
Error! 22
Error! 23
Error! 24
array(12) {
[0]=>
string(11) "84951234567"
[1]=>
string(11) "84951234567"
[2]=>
string(11) "84951234567"
[3]=>
string(11) "88122565656"
[4]=>
string(11) "89111234567"
[5]=>
string(11) "89111234567"
[6]=>
string(11) "89111234567"
[7]=>
string(11) "89111234567"
[8]=>
string(11) "89991234567"
[9]=>
string(11) "89091234567"
[10]=>
string(11) "89991234567"
[11]=>
string(11) "89525851255"
}