fork download
  1. <?php
  2.  
  3. $regexp = '/^(8|[+][ ]*7)([() -]?[0-9][() -]?){10}$/u';
  4. $trash = '/[() -]/u';
  5. $pureText = '+7(812)67)8 -67(67';
  6. $anotherTrash = '/^[+]7/u';
  7. $text = preg_replace($anotherTrash, '8', $pureText);
  8.  
  9. if(preg_match($regexp, $text)){
  10. $pureNumArray = preg_split($trash, $text);
  11. foreach($pureNumArray as $Num){
  12. $pureNum = $pureNum . $Num;
  13. };
  14. echo "Ваш номер {$pureNum}\n";
  15. }else{
  16. echo "Введенный номер неверен\n";
  17. };
Success #stdin #stdout #stderr 0.02s 52472KB
stdin
Standard input is empty
stdout
Ваш номер 88126786767
stderr
PHP Notice:  Undefined variable: pureNum in /home/KZQmiP/prog.php on line 13