<?php
$text = "Кажется, нас обнаружили! Надо срочно уходить отсюда, пока не поздно. Бежим же скорее!" ;
// Другие варианты для тестов
// $text = "Ну, прости меня! Не хотела я тебе зла сделать; да в себе не вольна была. Что говорила, что делала, себя не помнила.";
// $text = "Идет гражданская война. Космические корабли повстанцев, наносящие удар с тайной базы, одержали первую победу, в схватке со зловещей Галактической Империей.";
function makeTextlower ( $text ) {
return ( $lowerText ) ;
}
function firstLetterUpper ( $text ) {
return ( $firstLetter ) ;
}
function reverseSentence ( $sentence ) {
$words = preg_split ( '/[ ,]/' , $sentence , 0 , PREG_SPLIT_NO_EMPTY
) ; $result = implode ( ' ' , $reverseArray ) ; return ( $result ) ;
}
function reverseText ( $text ) {
$sentence = preg_split ( '/[.?!]/u' , $text , 0 , PREG_SPLIT_NO_EMPTY
) ; foreach ( $sentence as $key => $value ) {
$sentence2 = reverseSentence ( $value ) ;
$sentence3 = firstLetterUpper ( $sentence2 ) ;
$result .= $sentence3 . '. ' ;
}
return ( $result ) ;
}
function yodaText ( $text ) {
$a = makeTextlower ( $text ) ;
$b = reverseText ( $a ) ;
return ( $b ) ;
}
$yodaText = yodaText ( $text ) ;
echo "Йода говорит: {$yodaText} \n " ;
PD9waHAKIAplcnJvcl9yZXBvcnRpbmcoLTEpOwptYl9pbnRlcm5hbF9lbmNvZGluZygndXRmLTgnKTsKIAokdGV4dCA9ICLQmtCw0LbQtdGC0YHRjywg0L3QsNGBINC+0LHQvdCw0YDRg9C20LjQu9C4ISDQndCw0LTQviDRgdGA0L7Rh9C90L4g0YPRhdC+0LTQuNGC0Ywg0L7RgtGB0Y7QtNCwLCDQv9C+0LrQsCDQvdC1INC/0L7Qt9C00L3Qvi4g0JHQtdC20LjQvCDQttC1INGB0LrQvtGA0LXQtSEiOwovLyDQlNGA0YPQs9C40LUg0LLQsNGA0LjQsNC90YLRiyDQtNC70Y8g0YLQtdGB0YLQvtCyCi8vICR0ZXh0ID0gItCd0YMsINC/0YDQvtGB0YLQuCDQvNC10L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