<?php
$text = "Кажется, нас обнаружили! Надо срочно уходить отсюда, пока не поздно. Бежим же скорее!" ;
//$text = "Ну, прости меня! Не хотела я тебе зла сделать; да в себе не вольна была. Что говорила, что делала, себя не помнила.";
//$text = "Идет гражданская война. Космические корабли повстанцев, наносящие удар с тайной базы, одержали первую победу, в схватке со зловещей Галактической Империей.";
/* Делает первую букву предложения заглавной */
function makeFirstletterUppercase( $text ) {
}
function makeYodaStyleText( $text ) {
$result = '' ;
$regInt = '/[,;:]?\\s/' ; # Разделяет слова
$regExt = '/[.!?]/' ; # Разделяет предложения
$signExt = 0 ;
$lines = preg_split ( $regExt , $text , - 1 , PREG_SPLIT_NO_EMPTY
) ;
foreach ( $lines as $key => $line ) {
}
$signInt = 0 ;
$line_rev = '' ;
foreach ( $words_rev as $key => $word ) {
$line_rev .= $word . $signsInt_rev [ $signInt ] ;
$signInt ++;
}
$line_rev = makeFirstletterUppercase( $line_rev ) ;
$result .= $line_rev . $signsExt [ 0 ] [ $signExt ] . ' ' ;
$signExt ++;
}
return $result ;
}
$yodaText = makeYodaStyleText( $text ) ;
echo "Йода говорит: {$yodaText} \n " ;
PD9waHAKCmVycm9yX3JlcG9ydGluZygwKTsKbWJfaW50ZXJuYWxfZW5jb2RpbmcoJ3V0Zi04Jyk7CgokdGV4dCA9ICLQmtCw0LbQtdGC0YHRjywg0L3QsNGBINC+0LHQvdCw0YDRg9C20LjQu9C4ISDQndCw0LTQviDRgdGA0L7Rh9C90L4g0YPRhdC+0LTQuNGC0Ywg0L7RgtGB0Y7QtNCwLCDQv9C+0LrQsCDQvdC1INC/0L7Qt9C00L3Qvi4g0JHQtdC20LjQvCDQttC1INGB0LrQvtGA0LXQtSEiOwovLyR0ZXh0ID0gItCd0YMsINC/0YDQvtGB0YLQuCDQvNC10L3RjyEg0J3QtSDRhdC+0YLQtdC70LAg0Y8g0YLQtdCx0LUg0LfQu9CwINGB0LTQtdC70LDRgtGMOyDQtNCwINCyINGB0LXQsdC1INC90LUg0LLQ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