<?php
$text3 = "Кажется, нас обнаружили! Надо срочно уходить отсюда, пока не поздно. Бежим же скорее!" ;
// Другие варианты для тестов
$text2 = "Ну, прости меня! Не хотела я тебе зла сделать; да в себе не вольна была. Что говорила, что делала, себя не помнила." ;
$text1 = "Идет гражданская война. Космические корабли повстанцев, наносящие удар с тайной базы, одержали первую победу, в схватке со зловещей Галактической Империей." ;
/* Делает первую букву предложения заглавной */
function makeFirstletterUppercase( $text ) {
// foreach ($text as $value) {
// $value = trim($value);
// $value = mb_strtolower($value);
// $first = mb_strtoupper(mb_substr($value, 0, 1));
// $last = mb_substr($value, 1);
// $value = $first . $last;
// }
for ( $i = 0 ; $i < $length ; $i ++ ) {
$text [ $i ] = trim ( $text [ $i ] ) ; $text [ $i ] = $first . $last ;
}
}
function makeYodaStyleText( $text ) {
$text = preg_split ( "/[.!?]/u" , $text , 0 , PREG_SPLIT_NO_EMPTY
) ; // foreach ($text as $value) {
// $words = preg_split("/[\\s]|[,]|[;]/u", $text[$i], 0, PREG_SPLIT_NO_EMPTY);
// $value = implode(" ", array_reverse($words)) . ".";
// }
for ( $i = 0 ; $i < $length ; $i ++ ) {
$words = preg_split ( "/[\\ s]|[,]|[;]/u" , $text [ $i ] , 0 , PREG_SPLIT_NO_EMPTY
) ; }
return makeFirstletterUppercase( $text ) ;
}
$yodaText = makeYodaStyleText( $text1 ) ;
echo "Йода говорит: {$yodaText} \n " ;
$yodaText = makeYodaStyleText( $text2 ) ;
echo "Йода говорит: {$yodaText} \n " ;
$yodaText = makeYodaStyleText( $text3 ) ;
echo "Йода говорит: {$yodaText} \n " ;
PD9waHAKZXJyb3JfcmVwb3J0aW5nKC0xKTsKbWJfaW50ZXJuYWxfZW5jb2RpbmcoJ3V0Zi04Jyk7CgokdGV4dDMgPSAi0JrQsNC20LXRgtGB0Y8sINC90LDRgSDQvtCx0L3QsNGA0YPQttC40LvQuCEg0J3QsNC00L4g0YHRgNC+0YfQvdC+INGD0YXQvtC00LjRgtGMINC+0YLRg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