<?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) {
$text = preg_split('#[?!.]#u', $text, -1, PREG_SPLIT_NO_EMPTY
); foreach ($text as $key => $letter){
$text[$key] = trim($text[$key]); $text[$key] = preg_split('//u', $text[$key], -1, PREG_SPLIT_NO_EMPTY
); $text[$key] = implode("", $text[$key]); }
return $text;
}
/* исправляет текст */
function fixText($text){
$text = makeFirstLetterUppercase($text);
$reg = '#([a-zа-я](" ")*[.?!])#u';
$reg2 = '#((" ")*\\,(" ")#';
return $text;
}
$result = fixText($text);
echo "{$result}\n";
PD9waHAKCmVycm9yX3JlcG9ydGluZygtMSk7Cm1iX2ludGVybmFsX2VuY29kaW5nKCd1dGYtOCcpOwoKJHRleHQgPSAi0L3RgyDRh9GC0L4uICAgICAg0L3QtSDRgdC80L7RgtGA0LXQuyDQtdGJ0LUgYmxhY2sgbWVzYS7RjyDRgdC+0LHQuNGA0LDQu9GB0Y8g0YHQutCw0YfQsNGC0YwgICzQvdC+INCy0YHQtSDQutCw0Lot0YLQviDQvdC10LrQvtCz0LTQsCDQsdGL0LvQvi4iOwovLyDQlNC70Y8g0YLQtdGB0YLQvtCyCi8vICR0ZXh0ID0gJ3Jvc2VzIGFyZSByZWQsYW5kIHZpb2xldHMgYXJlIGJsdWUud2hhdGV2ZXIgeW91IGRvIGknbGwga2VlcCBpdCBmb3IgeW91Lic7Ci8vICR0ZXh0ID0gJ9C/0YDQuNCy0LXRgi7QtdGB0YLRjCAyINGE0YPQvdC60YbQuNC4LHByZWdfc3BsaXQg0LggZXhwbG9kZSAs0L3QtSDQv9C+0L3QuNC80LDRjizQsiDRh9C10Lwg0LzQtdC20LTRgyDQvdC40LzQuCDRgNCw0LfQvdC40YbQsC4nOwoKL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