fork download
  1. <?php
  2.  
  3.  
  4. $text = "Аргентина манит негра";
  5. $lowText = mb_strtolower($text);
  6. $a = 0;
  7. $b = -1;
  8. $noSpace = str_replace(" ", "", $lowText);
  9. $countText = mb_strlen($noSpace);
  10. $halfLenght = floor($countText / 2);
  11. for ($i = 0; $i <= $halfLength; $i++) {
  12.  
  13. $letter1 = mb_substr($noSpace, $a, 1);
  14. $letter2 = mb_substr($noSpace, $b, 1);
  15. $a++;
  16. $b--;
  17. if ($letter1 != $letter2) {
  18. $palindrome = false;
  19. break;
  20. }
  21. else {
  22. $palindrome = true;
  23. }
  24. }
  25. if ($palindrome = true) {
  26. echo "Это Полиндром";
  27. }
  28. else {
  29. echo "Это не полиндром";
  30. }
Success #stdin #stdout #stderr 0.02s 52472KB
stdin
Standard input is empty
stdout
Это  Полиндром
stderr
PHP Notice:  Undefined variable: halfLength in /home/1WOGIM/prog.php on line 13
PHP Notice:  Undefined variable: halfLength in /home/1WOGIM/prog.php on line 13