fork download
  1. <?php
  2.  
  3.  
  4. $text = 'Аргентина манит негра';
  5.  
  6. $text_lower = mb_strtolower($text);
  7. $codeTable = array(' ' => '');
  8. $without_space = strtr($text_lower, $codeTable);
  9. $result = "Pal";
  10.  
  11. $length = mb_strlen($text);
  12. $half = floor($length / 2);
  13.  
  14. for ($i = 0; $i <= $half; $i++) {
  15. $one = mb_substr($without_space, $i, 1);
  16. $two = mb_substr($without_space, -$i-1, 1);
  17. if ($one != $two) {
  18. $result = 'Not pal';
  19. break;
  20. }
  21. }
  22.  
  23. echo "$result";
Success #stdin #stdout 0.01s 52488KB
stdin
Standard input is empty
stdout
Pal