Advertisement
Guest User

Untitled

a guest
Dec 20th, 2014
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. <?php
  2. $text = $_GET['text'];
  3.  
  4. $newText = "";
  5. $word = "";
  6.  
  7. for ($i=0; $i < strlen($text); $i++) {
  8. if (ctype_alpha($text[$i])) {
  9. $word .= $text[$i];
  10. } else {
  11. if(ctype_upper($word)){
  12. if(strrev($word) == $word){
  13. for($j = 0; $j < strlen($word); $j++){
  14. $newText .= $word[$j] . $word[$j];
  15. }
  16. } else {
  17. $newText .= strrev($word);
  18. }
  19.  
  20. } else {
  21. $newText .= $word;
  22. }
  23. $newText .= $text[$i];
  24. $word = "";
  25. }
  26. }
  27.  
  28. echo '<p>' . htmlspecialchars($newText) .'</p>';
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement