fork download
  1. <?php
  2.  
  3.  
  4. $text = "Аргентина любит негра";
  5. $result= "Палиндром";
  6. $result2= "Не палиндром";
  7. $text = mb_strtolower($text);
  8.  
  9. $text = str_replace(" ","",$text);
  10.  
  11. $length = mb_strlen($text);
  12. $halfLength = floor($length/2);
  13. for ($i=0; $i==$halfLength; $i++) {
  14. $o=-$i-1;
  15. $comparison1=mb_substr($text,$i,1);
  16. $comparison2=mb_substr($text,$o,1);
  17. echo "$comparison1 \n";
  18. echo "$comparison2 \n";
  19. if ($comparison1==$comparison2) {
  20. $word1=$word1 . $comparison1;
  21. $word1=$word1 . $comparison1;
  22. } else {
  23. echo "Результат: $result2";
  24. }}
  25. if($word1==$word2) {
  26. echo "Результат: $result \n";
  27. }
  28.  
Success #stdin #stdout #stderr 0.02s 24448KB
stdin
Standard input is empty
stdout
Результат: Палиндром 
stderr
PHP Notice:  Undefined variable: word2 in /home/rUmseS/prog.php on line 26
PHP Notice:  Undefined variable: word1 in /home/rUmseS/prog.php on line 26