<?php
//$text = "ну что. не смотрел еще black mesa .я собирался скачать , но все как-то некогда было.";
// Для тестов
$text = "roses are red,and violets are blue.whatever you do i'll keep it for you." ;
//$text = 'привет.есть 2 функции,preg_split и explode ,не понимаю,в чем между ними разница.';
/* Делает первую букву в строке заглавной */
function makeFirstLetterUppercase( $text ) {
$explodedText = preg_split ( "/[.?!]/u" , $text , 0 , PREG_SPLIT_NO_EMPTY
) ; $count = count ( $explodedText ) ; for ( $i = 0 ; $i < $count ; $i ++ ) {
$explodedText [ 1 ] = trim ( $explodedText [ 1 ] ) ; $explodedText [ $i ] = mb_ucfirst( $explodedText [ $i ] ) ;
}
return ( $text ) ;
}
/* исправляет текст */
function fixText( $text ) {
$patterns [ 1 ] = '/(\\s+)?,(\\s+)?/u' ;
$patterns [ 2 ] = '/$/u' ;
$replacements [ 1 ] = ", " ;
$replacements [ 2 ] = "." ;
return ( $text ) ;
}
function mb_ucfirst( $str , $encoding = NULL )
{
if ( $encoding === NULL )
{
}
}
function ucfirst_utf8( $str )
{
}
$text = makeFirstLetterUppercase( $text ) ;
$result = fixText( $text ) ;
echo "{$result} \n " ;
PD9waHAKCmVycm9yX3JlcG9ydGluZygtMSk7Cm1iX2ludGVybmFsX2VuY29kaW5nKCd1dGYtOCcpOwoKLy8kdGV4dCA9ICLQvdGDINGH0YLQvi4gICAgICDQvdC1INGB0LzQvtGC0YDQtdC7INC10YnQtSBibGFjayBtZXNhIC7RjyDRgdC+0LHQuNGA0LDQu9GB0Y8g0YHQutCw0YfQsNGC0YwgICAgLCAgICAg0L3QviDQstGB0LUg0LrQsNC6LdGC0L4g0L3QtdC60L7Qs9C00LAg0LHRi9C70L4uIjsKLy8g0JTQu9GPINGC0LXRgdGC0L7QsgokdGV4dCA9ICJyb3NlcyBhcmUgcmVkLGFuZCB2aW9sZXRzIGFyZSBibHVlLndoYXRldmVyIHlvdSBkbyBpJ2xsIGtlZXAgaXQgZm9yIHlvdS4iOwovLyR0ZXh0ID0gJ9C/0YDQuN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