fork download
  1. <?php
  2.  
  3. $text = "ну что. не смотрел еще black mesa.я собирался скачать ,но все как-то некогда было.";
  4. // Для тестов
  5. //$text = 'roses are red,and violets are blue.whatever you do ill keep it for you.';
  6. //$text = "привет.есть 2 функции,preg_split и explode ,не понимаю,в чем между ними разница.";
  7.  
  8. /* исправляет текст */
  9. function fixText($text) {
  10. $separation = preg_split("/[.]/u", $text, -1, PREG_SPLIT_NO_EMPTY);
  11. $regex = '/^\\s/u';
  12.  
  13. foreach ($separation as $value) {
  14. $regexSpace = '/^\\s+/u';
  15. $clearSpace = preg_replace($regexSpace, '', $value);
  16. $first = mb_substr($clearSpace, 0, 1, 'UTF-8');//первая буква
  17. $last = mb_substr($clearSpace, 1);//все кроме первой буквы
  18. $first = mb_strtoupper($first, 'UTF-8');
  19. $last = mb_strtolower($last, 'UTF-8');
  20. $name1 = $first.$last;
  21. $fistLetterUpper[] = $name1;
  22. $madeFirstLetterUp = implode(". ", $fistLetterUpper);
  23. }
  24. $fix = preg_replace("/(\\s+)?,(\\s+)?+/", ", ", $madeFirstLetterUp);
  25. $finished = $fix.".";
  26. return $finished;
  27. }
  28.  
  29. $result = fixText($text);
  30. echo "{$result}\n";
  31. ?>
  32. // your code goes here
Runtime error #stdin #stdout #stderr 0.02s 23476KB
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/677ivE/prog.php:3
Stack trace:
#0 {main}
  thrown in /home/677ivE/prog.php on line 3