fork download
  1. <?php
  2.  
  3.  
  4.  
  5. $text = "Аргентина манит негра";
  6. $result = "палиндром";
  7. $text = mb_strtolower($text);
  8. $text = str_replace(" ", "", $text);
  9.  
  10. $length = mb_strlen ($text);
  11. $halfLength = floor($length/2);
  12.  
  13. $length = $length - 1;
  14. $letters = preg_split('//u', $text, null, PREG_SPLIT_NO_EMPTY);
  15. for ($i=0; $i <= $halfLength; $i++) {
  16. if ($letters[$i] !== $letters[$length - $i]) {
  17. $result = "не палиндром";
  18. break;
  19. }
  20. }
  21. 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/mu2dkq/prog.php:5
Stack trace:
#0 {main}
  thrown in /home/mu2dkq/prog.php on line 5