• Source
    1.  
    2. <?php
    3. error_reporting(-1);
    4. header("Content-Type: text/plain; charset=utf-8");
    5. mb_internal_encoding('utf-8');
    6.  
    7. $text1 = "ну что. не смотрел еще black mesa.я собирался скачать ,но все как-то некогда было.";
    8. $text = "roses are red,and violets are blue.whatever you do i'll keep it for you.";
    9. $text2 = 'привет.есть 2 функции,preg_split и explode ,не понимаю,в чем между ними разница.';
    10.  
    11. function fix($text)
    12. {
    13. //$array=preg_split('/\./u',$text);
    14. $array=explode(".",$text);
    15. foreach($array as &$value)
    16. {
    17. $firstChar=mb_substr($value,0,1,'utf-8');
    18. $firstChar=mb_strtoupper($firstChar,'utf-8');
    19. $value=substr_replace($value,$firstChar,0,1);
    20. $value=preg_replace('/ *\, */u',', ',$value);
    21. //$value=mb_ereg_replace('/ *\, */u',', ',$value);
    22. //$value=str_replace(",", ", ", $value);
    23. }
    24.  
    25. return implode(". ",$array);
    26. }
    27.  
    28. echo fix($text),"\n";
    29. echo fix($text1),"\n";
    30. echo fix($text2),"\n";
    31. ?>