fork download
  1. <?php
  2. $text = "+8-(050)-934 ";
  3. $regexp = '/^8[0-9]{10}$/';
  4. $text = str_replace(" ", "", $text);
  5. $text = str_replace("+", "", $text);
  6. $text = str_replace("-", "", $text);
  7. $text = str_replace("(", "", $text);
  8. $text = str_replace(")", "", $text);
  9.  
  10. if (preg_match($regexp, $text)){
  11. echo "Всё правильно";
  12. } else {
  13. echo "Ошибка";
  14. }
  15.  
Success #stdin #stdout 0.01s 20520KB
stdin
Standard input is empty
stdout
Ошибка