fork(1) download
  1. <?php
  2.  
  3. // номер
  4.  
  5. $number = "8 (911) - 123 - 45 - 67";
  6. $regExp = "/^(\+ *7| *8)([ ()-]*\d){10}$/m";
  7. $regExp1 = "/^(\+ *7| *8)/";
  8. $regExp2 = "/ |-|\(|\)/";
  9. if (preg_match($regExp, $number)) {
  10. $result = preg_replace($regExp1, "8" , $number);
  11. $result = preg_replace($regExp2, "" , $result);
  12. }
  13. echo $result;
Success #stdin #stdout 0.03s 52480KB
stdin
Standard input is empty
stdout
89111234567