fork download
  1. <?php
  2.  
  3.  
  4. $input = '8-(095)-506 56 56';
  5. $symbols = "/[(]|[)]|-|[+]|\\s/";
  6. $input = preg_replace ($symbols, '', $input);
  7.  
  8. $regexp = '/^[3]?[8]?(0[0-9]{2})([0-9]{7})$/';
  9. $m = array();
  10.  
  11. if (preg_match($regexp, $input, $m)) {
  12. echo "$input\nВсе верно";
  13. } else {
  14. echo "Введите еще раз";
  15. }
  16.  
Success #stdin #stdout 0.02s 52480KB
stdin
Standard input is empty
stdout
80955065656
Все верно