fork download
  1. <?php
  2.  
  3.  
  4. $text = "А роза упала на лапу Азора";
  5.  
  6. $text = mb_strtolower($text);
  7. $text = str_replace(" ","",$text);
  8.  
  9. $length = mb_strlen($text);
  10. $halfLength = floor($length/2);
  11.  
  12. for ($i = 0; $i <= $halfLength; $i++) {
  13. if (mb_substr($text,$i,1) == mb_substr($text,-($i+1),1)) {
  14. $result = "YES";
  15. }
  16. else {
  17. $result = "NO";
  18. break;
  19. }
  20. }
  21. echo $result;
  22.  
Success #stdin #stdout 0.01s 52488KB
stdin
Standard input is empty
stdout
YES