fork(1) download
  1. <?php
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9. $text = "А роза упала на лапу азора";
  10.  
  11. $noProb = str_replace(' ','',$text);
  12.  
  13. $downStr = mb_strtolower($noProb);
  14.  
  15.  
  16.  
  17. $length = mb_strlen($downStr);
  18.  
  19. $halfLength = floor($length/2);
  20.  
  21. $half1 = "";
  22.  
  23. $half2 = "";
  24.  
  25.  
  26.  
  27. for ($i = 0;$i <= ($halfLength);$i++){
  28.  
  29. $half1 .= mb_substr($downStr ,$i,1);
  30.  
  31. }
  32.  
  33. for ($ad =$length;$ad >= ($halfLength);$ad--){
  34. $half2 .= mb_substr($downStr,$ad,1);
  35.  
  36. }
  37.  
  38. echo " раз'$half1' два'$half2'\n";
  39.  
  40. ($half1== $half2) ? $result = "Это палиндром" : $result = "Не палиндром";
  41.  
  42. echo $result;
  43.  
Success #stdin #stdout 0.01s 20568KB
stdin
Standard input is empty
stdout
 раз'арозаупалан' два'арозаупалан'
Это палиндром