fork download
  1. <?php
  2.  
  3.  
  4. $text = "много их в Петербурге,молоденьких дур,сегодня в атласе да бархате,
  5. а завтра , поглядишь , метут улицу вместе с голью кабацкою...в самом деле
  6. ,что было бы с нами ,если бы вместо общеудобного правила:чин чина почитай ,
  7. ввелось в употребление другое,например:ум ума почитай???какие возникли бы споры!!!";
  8.  
  9. function makeFirstLetterUppercase($text) {
  10. $allText = [];
  11. $splitText = preg_split("/(?<=[.!?](?![.!?]))/u", $text, 0, PREG_SPLIT_NO_EMPTY);
  12. foreach ($splitText as $texts) {
  13. $upper = mb_strtoupper(mb_substr($texts, 0, 1)) . mb_substr($texts, 1, null);
  14. array_push($allText, $upper);
  15. }
  16.  
  17. $complete = implode(" ", $allText);
  18. return $complete;
  19. }
  20.  
  21. function fixtext($text) { //исправляет текст
  22. $regexp = "/\s*([,:]{1})\s*/u";
  23. $replace = preg_replace($regexp, "$1 ", $text);
  24. return $replace;
  25. }
  26.  
  27. $first = makeFirstLetterUppercase($text);
  28. $second = fixtext($first);
  29.  
  30. echo $second;
Runtime error #stdin #stdout #stderr 0.02s 23576KB
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/amnqZd/prog.php:4
Stack trace:
#0 {main}
  thrown in /home/amnqZd/prog.php on line 4