fork download
  1. <?php
  2.  
  3.  
  4. $text="Аргентина манит негра";
  5. $result="палиндром";
  6.  
  7. $text=str_replace(" ","",$text);
  8. $text =mb_strtolower($text);
  9.  
  10. $lenght=mb_strlen($text);
  11. echo"{$lenght}\n";
  12. $halfText= floor($lenght/ 2);
  13.  
  14. for($i=0; $i<=$halfText; $i++) {
  15. $y[]=mb_substr($text,$i,1);
  16. }
  17. $y=implode($y);
  18. for($i=200; $i>=$halfText; $i--) {
  19. $x[]=mb_substr($text,$i,1);
  20. }
  21. $x=implode($x);
  22. if ($x==$y) {
  23. echo $result;
  24. }
  25. else {
  26. echo"niet";
  27. }
Success #stdin #stdout 0.02s 24456KB
stdin
Standard input is empty
stdout
19
палиндром