<?php
$text1 = "ну что. не смотрел еще black mesa.я собирался скачать ,но все как-то некогда было." ;
$text2 = "roses are red,and violets are blue.whatever you do i'll keep it for you." ;
$text3 = "привет.есть 2 функции,preg_split и explode ,не понимаю,в чем между ними разница." ;
function fixText( $text ) {
$text1 = preg_replace ( "!(\ )+!iu" , " " , $text ) ; //Убираем лишние проблемы $text2 = preg_replace ( "!(\ )?\,(\ )?!iu" , ", " , $text1 ) ; //Делаем пробел после запятой $text3 = preg_replace ( "!(\ )?\.(\ )?!iu" , ". " , $text2 ) ; //и после точки foreach ( $text4 as $key => $sentence ) { //
$firstLetter = mb_substr ( $sentence , 0 , 1 ) ; //Делаем первую $firstLetterUpper = mb_strtoupper ( $firstLetter ) . //букву предложения $text4 = str_replace ( $sentence , $firstLetterUpper , $text4 ) ; // } //
$result = implode ( ". " , $text4 ) ; // return $result ;
}
$result1 = fixText( $text1 ) ;
echo "$result1 \n " ;
$result2 = fixText( $text2 ) ;
echo "$result2 \n " ;
$result3 = fixText( $text3 ) ;
echo "$result3 \n " ;
?>
PD9waHAKIAplcnJvcl9yZXBvcnRpbmcoLTEpOwptYl9pbnRlcm5hbF9lbmNvZGluZygndXRmLTgnKTsKIAokdGV4dDEgPSAi0L3RgyDRh9GC0L4uICAgICAg0L3QtSDRgdC80L7RgtGA0LXQuyDQtdGJ0LUgYmxhY2sgbWVzYS7RjyDRgdC+0LHQuNGA0LDQu9GB0Y8g0YHQutCw0YfQsNGC0YwgICzQvdC+INCy0YHQtSDQutCw0Lot0YLQviDQvdC10LrQvtCz0LTQsCDQsdGL0LvQvi4iOwokdGV4dDIgPSAicm9zZXMgYXJlIHJlZCxhbmQgdmlvbGV0cyBhcmUgYmx1ZS53aGF0ZXZlciB5b3UgZG8gaSdsbCBrZWVwIGl0IGZvciB5b3UuIjsKJHRleHQzID0gItC/0YDQuNCy0LXRgi7QtdGB0YLRjCAyINGE0YPQvdC60YbQuNC4LHByZWdfc3BsaXQg0LggZXhwbG9kZSAs0L3QtS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