fork download
  1. <?php
  2. $number = '8 (911) - 123 - 45 - 67';
  3. $regExp = '/^ ?(8|\\+ ?7)([ \\-()]*[0-9]){10}$/';
  4. $regSpace = '/[ ()\-]/';
  5. $regCode = '/\\+7/';
  6. if (preg_match($regExp, $number)) {
  7. $symbols = preg_replace($regSpace, '',$number);
  8. $code = preg_replace($regCode, '8', $symbols);
  9. echo $code;
  10. } else {
  11. echo "Wrong number";
  12. }
Success #stdin #stdout 0.02s 52472KB
stdin
Standard input is empty
stdout
89111234567