fork(1) download
  1. <?php
  2. $text = "к";
  3. $result = "палиндром";
  4. $text = mb_strtolower(str_replace(" ", "",$text));
  5. echo $text . "\n";
  6. $length = mb_strlen($text);
  7. $halfLength = floor($length/2);
  8.  
  9. for ($i = 0; $i <= $halfLength; $i++) {
  10. $left = mb_substr($text, $i, 1);
  11. $right = mb_substr($text, -$i-1, 1);
  12. if ($left != $right) {
  13. echo "Не полиндром";
  14. break;
  15. }elseif($i == $halfLength){
  16. echo $result;
  17. }
  18. }
Success #stdin #stdout 0.03s 52480KB
stdin
Standard input is empty
stdout
к
палиндром