fork(3) download
  1. <?php
  2. $regexp = "/^([+78])([0-9]{10})$/ui";
  3. $numbers = [
  4. '84951234567', '+74951234567', '8-495-1-234-567',
  5. ' 8 (8122) 56-56-56', '8-911-1234567', '8 (911) 12 345 67',
  6. '8-911 12 345 67', '8 (911) - 123 - 45 - 67', '+ 7 999 123 4567',
  7. '8 ( 999 ) 1234567', '8 999 123 4567'
  8. ];
  9.  
  10. $matches = [];
  11. foreach ($numbers as $number) {
  12. $correctText = str_replace(" ", "", $number);
  13. $correctText = str_replace("-", "", $correctText);
  14. $correctText = str_replace("(", "", $correctText);
  15. $correctText = str_replace(")", "", $correctText);
  16. if (preg_match($regexp, $correctText, $matches)) {
  17. echo "Правильный номер: {$matches[0]}<br/>";
  18. } else {
  19. echo "Ошибка! Введите номер формата: +7/8xxxxxxxxxx<br/>";
  20. }
  21. }
  22. ?>
Runtime error #stdin #stdout #stderr 0.02s 23708KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
PHP Fatal error:  Uncaught Error: Call to undefined function mb_internal_encoding() in /home/rHDfhB/prog.php:2
Stack trace:
#0 {main}
  thrown in /home/rHDfhB/prog.php on line 2