fork download
  1.  
  2. <?php
  3. header("Content-Type: text/plain; charset=utf-8");
  4.  
  5. $text1 = "ну что. не смотрел еще black mesa.я собирался скачать ,но все как-то некогда было.";
  6. $text = "roses are red,and violets are blue.whatever you do i'll keep it for you.";
  7. $text2 = 'привет.есть 2 функции,preg_split и explode ,не понимаю,в чем между ними разница.';
  8.  
  9. function fix($text)
  10. {
  11. //$array=preg_split('/\./u',$text);
  12. $array=explode(".",$text);
  13. foreach($array as &$value)
  14. {
  15. $firstChar=mb_substr($value,0,1,'utf-8');
  16. $firstChar=mb_strtoupper($firstChar,'utf-8');
  17. $value=substr_replace($value,$firstChar,0,1);
  18. $value=preg_replace('/ *\, */u',', ',$value);
  19. //$value=mb_ereg_replace('/ *\, */u',', ',$value);
  20. //$value=str_replace(",", ", ", $value);
  21. }
  22.  
  23. return implode(". ",$array);
  24. }
  25.  
  26. echo fix($text),"\n";
  27. echo fix($text1),"\n";
  28. echo fix($text2),"\n";
  29. ?>
Success #stdin #stdout #stderr 0.01s 20568KB
stdin
Standard input is empty
stdout
Roses are red, and violets are blue. Whatever you do i'll keep it for you. 
.       не смотрел еще black mesa. . 
. . 
stderr
PHP Warning:  Cannot modify header information - headers already sent by (output started at /home/n60zTi/prog.php:2) in /home/n60zTi/prog.php on line 4