<?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]); }
return($text);
}
/* исправляет текст */
function fixText($text) {
$patterns[1]='/(\\s+)?,(\\s+)?/u';
$patterns[2]='/$/u';
$replacements[1]=", ";
$replacements[2]=".";
return($text);
}
$text=makeFirstLetterUppercase($text);
$result = fixText($text);
echo "{$result}\n";
ICAgPD9waHAKIAplcnJvcl9yZXBvcnRpbmcoLTEpOwptYl9pbnRlcm5hbF9lbmNvZGluZygndXRmLTgnKTsKIAokdGV4dCA9ICLQvdGDINGH0YLQvi4gICAgICDQvdC1INGB0LzQvtGC0YDQtdC7INC10YnQtSBibGFjayBtZXNhIC7RjyDRgdC+0LHQuNGA0LDQu9GB0Y8g0YHQutCw0YfQsNGC0YwgICAgLCAgICAg0L3QviDQstGB0LUg0LrQsNC6LdGC0L4g0L3QtdC60L7Qs9C00LAg0LHRi9C70L4uIjsKLy8g0JTQu9GPINGC0LXRgdGC0L7QsgovLyR0ZXh0ID0gInJvc2VzIGFyZSByZWQsYW5kIHZpb2xldHMgYXJlIGJsdWUud2hhdGV2ZXIgeW91IGRvIGknbGwga2VlcCBpdCBmb3IgeW91LiI7Ci8vJHRleHQgPSAn0L/RgNC40LLQtdGCLtC10YHRgtGMIDIg0YTRg9C90LrRhtC40LgscHJlZ19zcGxpdCDQuCBleHBsb2RlICzQvdC1INC/0L7QvdC40LzQsNGOLNCyINGH0LXQvCDQvNC10LbQtNGDINC90LjQvNC4INGA0LDQt9C90LjRhtCwLic7CiAKLyog0JTQtdC70LDQtdGCINC/0LXRgNCy0YP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