fork(1) download
  1. <?php
  2.  
  3. $text = "А роза упала на лапу Азора";
  4. $result = "Палиндром";
  5.  
  6. $text = str_replace(" ","", $text);
  7. $text = mb_strtolower($text);
  8.  
  9. $lenght = mb_strlen($text);
  10. $halfLenght = floor($lenght / 2);
  11.  
  12. for ($i = 0; $i <= $halfLenght; $i++) {
  13. $first = mb_substr ($text, 0, 1);
  14. $last = mb_substr ($text, -1);
  15. if ($first != $last)
  16. {
  17. $result = "Не палиндром";
  18. break;
  19. }
  20. $text = mb_substr ($text, 1);
  21. $text = mb_substr ($text, 0, -1);
  22. }
  23. 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/6bdsIG/prog.php:3
Stack trace:
#0 {main}
  thrown in /home/6bdsIG/prog.php on line 3