fork download
  1. <?php
  2.  
  3.  
  4. $text = "Кажется, нас обнаружили! Надо срочно уходить отсюда, пока не поздно. Бежим же скорее!";
  5.  
  6. function makeFirstLetterUppercase($text) {
  7. $firstUp = mb_strtoupper(mb_substr($text, 0, 1)) . mb_substr($text, 1, null);
  8. return $firstUp;
  9. }
  10.  
  11. function makeYodaStyleText($text) {
  12. $lowText = mb_strtolower($text);
  13. $sentence = preg_split("/[.!?]/u", $lowText, 0, PREG_SPLIT_NO_EMPTY);
  14. foreach ($sentence as $sentences) {
  15. $clearText = preg_replace("/[,;]/u", "", $sentences);
  16. $words = preg_split("/\\s/u", $clearText, 0, PREG_SPLIT_NO_EMPTY);
  17. $reverse = array_reverse($words);
  18. $resultString = implode(" ", $reverse) . ".";
  19. $text = makeFirstLetterUppercase($resultString);
  20. $yodaText[] = $text;
  21. }
  22. $port = implode(" ", $yodaText);
  23. return $port;
  24. }
  25.  
  26. $yodaStyle = makeYodaStyleText($text);
  27. echo $yodaStyle;
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/uGvt25/prog.php:4
Stack trace:
#0 {main}
  thrown in /home/uGvt25/prog.php on line 4