fork download
  1. <?php
  2. $numbers=array('+7(911)-506 56 56',
  3. '8-911-50-656-56',
  4. '89115065656',
  5. '02',
  6. '8-(9)_115 _065 6-3-5',//HURRR DURRRR
  7. '89115065656 позвать Люду');
  8.  
  9. $regular='/^(8|\+7)((( |-|\(|\)|_|)*[0-9]( |-|\(|\)|_|)*){9})[0-9]$/';
  10. $matches=preg_grep($regular,$numbers);
  11.  
  12. $regular='/\+7/';
  13. $matches=preg_replace($regular,"8",$matches);
  14.  
  15. $regular='/-|_|\)|\(| | /';
  16. $matches=preg_replace($regular,"",$matches);
  17. print_r($matches);
  18. ?>
Success #stdin #stdout 0.06s 20568KB
stdin
Standard input is empty
stdout
Array
(
    [0] => 89115065656
    [1] => 89115065656
    [2] => 89115065656
    [4] => 89115065635
)