<?php
$text3 = "Кажется, нас обнаружили! Надо срочно уходить отсюда, пока не поздно. Бежим же скорее!" ;
// Другие варианты для тестов
$text2 = "Ну, прости меня! Не хотела я тебе зла сделать; да в себе не вольна была. Что говорила, что делала, себя не помнила." ;
$text1 = "Идет гражданская война. Космические корабли повстанцев, наносящие удар с тайной базы, одержали первую победу, в схватке со зловещей Галактической Империей." ;
/* Делает первую букву предложения заглавной */
function makeFirstletterUppercase( $arr ) {
foreach ( $arr as $key => $suggestion ) {
$suggestion = trim ( $suggestion ) ; $arr [ $key ] = $firstChar . $lastChars ;
}
}
function makeYodaStyleText( $text ) {
$suggestions = preg_split ( "/[.!?]/u" , $text , 0 , PREG_SPLIT_NO_EMPTY
) ;
foreach ( $suggestions as $key => $suggestion ) {
$word = preg_split ( "/[\\ s,;]/u" , $suggestion , 0 , PREG_SPLIT_NO_EMPTY
) ; }
return makeFirstletterUppercase( $suggestions ) ;
}
$yodaText = makeYodaStyleText( $text1 ) ;
echo "Йода говорит: {$yodaText} \n " ;
$yodaText = makeYodaStyleText( $text2 ) ;
echo "Йода говорит: {$yodaText} \n " ;
$yodaText = makeYodaStyleText( $text3 ) ;
echo "Йода говорит: {$yodaText} \n " ;
PD9waHAKZXJyb3JfcmVwb3J0aW5nKC0xKTsKbWJfaW50ZXJuYWxfZW5jb2RpbmcoJ3V0Zi04Jyk7CiR0ZXh0MyA9ICLQmtCw0LbQtdGC0YHRjywg0L3QsNGBINC+0LHQvdCw0YDRg9C20LjQu9C4ISDQndCw0LTQviDRgdGA0L7Rh9C90L4g0YPRhdC+0LTQuNGC0Ywg0L7RgtGB0Y7QtNCwLCDQv9C+0LrQsCDQvdC1INC/0L7Qt9C00L3Qvi4g0JHQtdC20LjQvCDQttC1INGB0LrQvtGA0LXQtSEiOwovLyDQlNGA0YPQs9C40LUg0LLQsNGA0LjQsNC90YLRiyDQtNC70Y8g0YLQtdGB0YLQvtCyCiR0ZXh0MiA9ICLQndGDLCDQv9GA0L7RgdGC0Lgg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