fork(2) download
  1. <?php
  2.  
  3.  
  4.  
  5.  
  6. $regexp = "/^\s*(([+]\s*7)|8)(\W*\d){10}\W*$/u";
  7.  
  8. $correctNumbers = array();
  9. $incorrectNumbers = array();
  10.  
  11. $numbers = array( '84951234567', '+74951234567', '8-495-1-234-567',
  12. ' 8 (8122) 56-56-56', '8-911-1234567', '8 (911) 12 345 67',
  13. '8-911 12 345 67', '8 (911) - 123 - 45 - 67', '+ 7 999 123 4567',
  14. '8 ( 999 ) 1234567', '8 999 123 4567','02', '84951234567 позвать люсю', '849512345', '849512345678',
  15. '8 (409) 123-123-123', '7900123467', '5005005001', '8888-8888-88',
  16. '84951a234567', '8495123456a',
  17. '+1 234 5678901',
  18. '+8 234 5678901',
  19. '7 234 5678901' );
  20.  
  21. foreach ($numbers as $num) {
  22. if (preg_match($regexp, $num)) {
  23. $correctNumbers[]= $num ;
  24. }
  25. }
  26. print_r($correctNumbers);
  27.  
  28.  
  29.  
  30. ?>
  31.  
Success #stdin #stdout 0s 82944KB
stdin
Standard input is empty
stdout
Array
(
    [0] => 84951234567
    [1] => +74951234567
    [2] => 8-495-1-234-567
    [3] =>  8 (8122) 56-56-56
    [4] => 8-911-1234567
    [5] => 8 (911) 12 345 67
    [6] => 8-911 12 345 67
    [7] => 8 (911) - 123 - 45 - 67
    [8] => + 7 999 123 4567
    [9] => 8 ( 999 ) 1234567
    [10] => 8 999 123 4567
)