fork download
  1. <?php
  2.  
  3.  
  4. $inputData ='+7-911-404-44-11';
  5. $regexp ='!^\\+7|8-?\\(?-?[0-9]{3}\\)?-?[0-9]{3}-?[0-9]{2}-?[0-9]{2}$!';
  6. $regexp1 ='![^0-9]!';
  7. $regexp2 ='!7[0-9]!';
  8. $regexp3 = '[^012345689]';
  9. if (preg_match($regexp, $inputData)) {
  10. $result =preg_replace($regexp1, '', $inputData);
  11.  
  12. } else {
  13. echo "Пожалуйста введите номер в верном формате.\n";
  14. }
  15. if (preg_match($regexp2, $result)) {
  16. $result1= preg_replace($regexp3, '8', $result);
  17. } else {
  18. $result1=$result;
  19. }
  20. echo $result1;
Success #stdin #stdout 0.01s 20568KB
stdin
Standard input is empty
stdout
79114044411