fork download
  1. <?php
  2.  
  3.  
  4. $text = "хух";
  5. $noProb = str_replace(' ','',$text);
  6. $downStr = mb_strtolower($noProb);
  7.  
  8. $length = mb_strlen($downStr);
  9. $halfLength = floor($length/2);
  10. $half1 = "";
  11. $half2 = "";
  12.  
  13. for ($i = 0;$i <= ($halfLength);$i++){
  14. $half1 .= mb_substr($downStr ,$i,1);
  15. }
  16. for ($ad =$length;$ad <= ($halfLength);$ad--){
  17. $half2 .= mb_substr($downStr,$ad,-1);
  18. }
  19. echo " раз'$half1' два'$half2'";
  20. if ($half1 = $half2){
  21. echo "палиндром";
  22.  
  23. }
  24. elseif($half1 != $half2){
  25. echo "не палиндром";
  26. }
  27.  
Success #stdin #stdout 0.01s 20520KB
stdin
Standard input is empty
stdout
 раз'ху' два''