fork download
  1. <?php
  2.  
  3.  
  4. $text = "А роза упала на лапу Азора";
  5. $result = "палидром";
  6.  
  7. $text = mb_strtolower($text);
  8. $words = explode(" ", $text);
  9. $words = count($words);
  10. $text = str_replace(" ", "", $text);
  11.  
  12. $length = mb_strlen($text);
  13. $halfLength = floor($length/2);
  14. $count = 0;
  15. for ($i = 0; $i <= $halfLength; $i++) {
  16. if(($text[$i]) == ($text[$length-$i-1])) {
  17. $count++;
  18. }
  19. }
  20. if ($count == $words) {
  21. echo $result;
  22. } else {
  23. echo "В другой раз";
  24. }
Success #stdin #stdout 0.02s 24560KB
stdin
Standard input is empty
stdout
палидром