fork download
  1. <?php
  2.  
  3. $text = "А роза упала на лапу азора";
  4. $result = "палиндром";
  5.  
  6. $text = mb_strtolower($text);
  7. $text = str_replace(" ", "", $text);
  8.  
  9. $lenght = mb_strlen($text);
  10. $halfLenght = floor($lenght/ 2);
  11.  
  12. for ($i = 0, $u = -1; $i < $halfLenght; $i++, $u--) {
  13. $stroka1 = mb_substr($text, $i, 1);
  14. $stroka2 = mb_substr($text, $u, 1);
  15.  
  16. if ($stroka1 != $stroka2) {
  17. $result = "не палиндром";
  18. break;
  19. }
  20. }
  21.  
  22. echo $result;
Runtime error #stdin #stdout #stderr 0.01s 82880KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
PHP Fatal error:  Uncaught Error: Call to undefined function mb_internal_encoding() in /home/rAPV9C/prog.php:3
Stack trace:
#0 {main}
  thrown in /home/rAPV9C/prog.php on line 3