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