<?php
$text = "Кажется, нас обнаружили! Надо срочно уходить отсюда, пока не поздно. Бежим же скорее!" ;
// $text = "Ну, прости меня! Не хотела я тебе зла сделать; да в себе не вольна была. Что говорила, что делала, себя не помнила.";
// $text = "Идет гражданская война. Космические корабли повстанцев, наносящие удар с тайной базы, одержали первую победу, в схватке со зловещей Галактической Империей.";
function makeFirstletterUppercase( $text , $arrayFilledWithSentences , $cutTheText ) {
$cleanAndUppercase = array ( ) ; $arrayFilledWithSentences ;
foreach ( $arrayFilledWithSentences as $keys => $values ) {
$findTheFirstLetter = mb_substr ( $values , 0 , 1 ) ; $makeTheRightSentences = $upTheFirstLetter . $cutTheFirstLetter ;
array_push ( $cleanAndUppercase , $makeTheRightSentences ) ; }
$theReadySentences = implode ( '. ' , $cleanAndUppercase ) ; return $theReadySentences ;
}
function makeYodaStyleText( $text ) {
$cutTheText = preg_split ( '/[.!?]\\s?/ui' , $undercasedAndCleanedText , 0 , PREG_SPLIT_NO_EMPTY
) ; $arrayFilledWithSentences = array ( ) ; foreach ( $cutTheText as $keys => $values ) {
$implodeReversedWordsInSentences = implode ( ' ' , $reverseWordsInSentences ) ; array_push ( $arrayFilledWithSentences , $implodeReversedWordsInSentences ) ; $theReadySentences = makeFirstletterUppercase( $text , $arrayFilledWithSentences , $cutTheText ) ;
}
return $theReadySentences ;
}
$yodaText = makeYodaStyleText( $text ) ;
echo "Йода говорит: {$yodaText} .\n " ;
?>
PD9waHAKCmVycm9yX3JlcG9ydGluZygtMSk7Cm1iX2ludGVybmFsX2VuY29kaW5nKCd1dGYtOCcpOwoKJHRleHQgPSAi0JrQsNC20LXRgtGB0Y8sINC90LDRgSDQvtCx0L3QsNGA0YPQttC40LvQuCEg0J3QsNC00L4g0YHRgNC+0YfQvdC+INGD0YXQvtC00LjRgtGMINC+0YLRgdGO0LTQsCwg0L/QvtC60LAg0L3QtSDQv9C+0LfQtNC90L4uINCR0LXQttC40Lwg0LbQtSDRgdC60L7RgNC10LUhIjsKLy8gJHRle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