function readWord($word) { $emotion_verb = processEmotionVerb($word); if (!is_null($emotion_verb)) { return $emotion_verb; } return processWord($word); }
<?php $text = $_GET['text']; $buffer = ""; $newText = ''; for ($i = 0; $i < strlen($text); $i++) { $ch = $text[$i]; if (ctype_alpha($ch)) { $buffer .= $ch; } else { $newText .= processWord($buffer); $buffer = ''; $newText .= $ch; } } $newText .= processWord($buffer); echo "<p>" . htmlspecialchars($newText) . "</p>"; function processWord($word) { if (ctype_upper($word)) { $reversed = strrev($word); if ($word == $reversed) { return doubleWord($word); } else { return $reversed; } } return $word; } function doubleWord($word) {