fork download
  1. <?php
  2.  
  3.  
  4. $text = "абвгде";
  5. $result = "палиндром";
  6.  
  7. $text = mb_strtolower($text);
  8. str_replace(" ","",$text);
  9.  
  10. $length = mb_strlen($text);
  11. $halfLength = floor($length/ 2);
  12.  
  13. for ($i = 0; $i <= halfLength; $i++) {
  14. $beginningLine = mb_substr($text, $halfLength);
  15. $endingLine = mb_substr($text, -$halfLength);
  16. }
  17. if ($beginningLine == $endingLine) {
  18. echo " Результат: {$result}\n";
  19. }
  20.  
Success #stdin #stdout #stderr 0.01s 52488KB
stdin
Standard input is empty
stdout
 Результат: палиндром
stderr
PHP Notice:  Use of undefined constant halfLength - assumed 'halfLength' in /home/RllPGe/prog.php on line 14
PHP Notice:  Use of undefined constant halfLength - assumed 'halfLength' in /home/RllPGe/prog.php on line 14