<?php
#---------------------------------------------------------------------------------------------------#
$text0 = "ну что. не смотрел еще black mesa.я собирался скачать ,но все как-то некогда было." ;
$text1 = "roses are red,and violets are blue.whatever you do i'll keep it for you." ;
$text2 = "привет!есть 2 функции,preg_split и explode ,не понимаю,в чем между ними разница?" ;
#---------------------------------------------------------------------------------------------------#
$texts = array ( $text0 , $text1 , $text2 ) ;
/* Делает первую букву в строке заглавной */
function makeFirstLetterUppercase( $text ) {
}
/* Убирает лишние пробелы */
function fixSpaces( $text ) {
$regexp = '/(\\s*)([,:;])(\\s*)/' ;
}
/* Исправляет текст */
function fixText( $text ) {
$signIndex = 0 ;
$regexp = '/[.?!]/' ;
$fixed = '' ;
$lines = preg_split ( $regexp , $text , - 1 , PREG_SPLIT_NO_EMPTY
) ; }
foreach ( $lines as $key => $line ) {
$capitalized = makeFirstLetterUppercase
( trim ( $line ) ) ; $fixed .= fixSpaces( $capitalized ) . $signes [ 0 ] [ $signIndex ] . ' ' ;
$signIndex ++;
}
echo "{$fixed} \n " ;
}
foreach ( $texts as $key => $text ) {
fixText( $text ) ;
}
PD9waHAKCmVycm9yX3JlcG9ydGluZygtMSk7Cm1iX2ludGVybmFsX2VuY29kaW5nKCd1dGYtOCcpOwoKIy0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLSMKJHRleHQwID0gItC90YMg0YfRgtC+LiAgICAgINC90LUg0YHQvNC+0YLRgNC10Lsg0LXRidC1IGJsYWNrIG1lc2Eu0Y8g0YHQvtCx0LjRgNCw0LvRgdGPINGB0LrQsNGH0LDRgtGMICAs0L3QviDQstGB0LUg0LrQsNC6LdGC0L4g0L3QtdC60L7Qs9C00LAg0LHRi9C70L4uIjsKJHRleHQxID0gInJvc2VzIGFyZSByZWQsYW5kIHZpb2xldHMgYXJlIGJsdWUud2hhd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