<?php
$text = "Кажется, нас обнаружили! Надо срочно уходить отсюда, пока не поздно. Бежим же скорее!";
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);
$result .= $sentence2;
}
return ($result);
}
$yodaText = reverseText($text);
echo "Йода говорит: {$yodaText}\n";
PD9waHAKCiR0ZXh0ID0gItCa0LDQttC10YLRgdGPLCDQvdCw0YEg0L7QsdC90LDRgNGD0LbQuNC70LghINCd0LDQtNC+INGB0YDQvtGH0L3QviDRg9GF0L7QtNC40YLRjCDQvtGC0YHRjtC00LAsINC/0L7QutCwINC90LUg0L/QvtC30LTQvdC+LiDQkdC10LbQuNC8INC20LUg0YHQutC+0YDQtdC1ISI7CgpmdW5jdGlvbiByZXZlcnNlU2VudGVuY2UgKCRzZW50ZW5jZSkgewogCSR3b3JkcyA9IHByZWdfc3BsaXQoJy9bICxdLycsICRzZW50ZW5jZSwgMCwgUFJFR19TUExJVF9OT19FTVBUWSk7CiAJJHJldmVyc2VBcnJheSA9IGFycmF5X3JldmVyc2UoJHdvcmRzKTsKIAkkcmVzdWx0ID0gaW1wbG9kZSgnICcsICRyZXZlcnNlQXJyYXkpOwoJcmV0dXJuICgkcmVzdWx0KTsKfQoKZnVuY3Rpb24gcmV2ZXJzZVRleHQgKCR0ZXh0KSB7Cgkkc2VudGVuY2UgPSBwcmVnX3NwbGl0KCcvWy4/IV0vdScsJHRleHQsMCxQUkVHX1NQTElUX05PX0VNUFRZKTsKCWZvcmVhY2ggKCRzZW50ZW5jZSBhcyAka2V5ID0+ICR2YWx1ZSkgewoJCSRzZW50ZW5jZTIgPSByZXZlcnNlU2VudGVuY2UgKCR2YWx1ZSk7CgkJJHJlc3VsdCAuPSAkc2VudGVuY2UyOwoJfQpyZXR1cm4gKCRyZXN1bHQpOwp9CiAKJHlvZGFUZXh0ID0gcmV2ZXJzZVRleHQoJHRleHQpOwplY2hvICLQmdC+0LTQsCDQs9C+0LLQvtGA0LjRgjogeyR5b2RhVGV4dH1cbiI7