<?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+0LHQvdCw0YDRg9C20LjQu9C4ISDQntC/0LDRgdC90L4hINCd0LDQtNC+INGB0YDQvtGH0L3QviDRg9GF0L7QtNC40YLRjCDQvtGC0YHRjtC00LAsINC/0L7QutCwINC90LUg0L/QvtC30LTQvdC+LiDQkdC10LbQuNC8INC20LUg0YHQutC+0YDQtdC1ISI7Ci8vJHRleHQgPSAi0J3Rgywg0L/RgNC+0YHRgtC4INC80LXQvdGPISDQndC1INGF0L7RgtC10LvQsCDRjyDRgtC10LHQtSDQt9C70LAg0YHQtNC10LvQsNGC0Yw7INC00LAg0LIg0YHQtdCx0LUg0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