fork download
  1. <?php
  2.  
  3.  
  4.  
  5. $text = "Сеньор-помидор пишет безошибочный код";
  6.  
  7.  
  8. $result = "палиндром";
  9.  
  10. $text = str_replace(' ', '', mb_strtolower($text));
  11.  
  12. $length = mb_strlen($text);
  13. $halfLength = floor($length / 2);
  14. $letters = preg_split('//u', $text);
  15.  
  16.  
  17. for ($i = 0; $i <= $halfLength; $i++) {
  18. if ($letters[$length - $i + 1] == $letters[$i])
  19. continue;
  20. else $result = "Не палиндром";
  21. }
  22.  
  23. echo $result;
  24.  
Success #stdin #stdout 0.02s 24504KB
stdin
Standard input is empty
stdout
Не палиндром