fork download
  1. <?php
  2.  
  3.  
  4. $text = "hello world";
  5.  
  6. $i = preg_split("![\ \,\.\:0-9]!", $text);
  7. $test = "!([а-яё]+)?[a-z]([а-яё]+)?!ui";
  8. $replace = array('a' => '[a]', 'c' => '[c]', 'e' => '[e]', 'o' => '[o]');
  9.  
  10.  
  11. foreach($i as $key => $word) {
  12.  
  13. if(preg_match($test, $word)) {
  14. echo "Опечатка в слове $word: ";
  15. $replaceWord = strtr($word, $replace);
  16. echo "$replaceWord\n";
  17. }
  18.  
  19. }
  20.  
  21. ?>
  22.  
Success #stdin #stdout 0.02s 52480KB
stdin
Standard input is empty
stdout
Опечатка в слове hello: h[e]ll[o]
Опечатка в слове world: w[o]rld