fork(2) download
  1. <?php
  2.  
  3.  
  4. $text = "A roza upala na lapu Azora";
  5. $result = "palindrome";
  6.  
  7. $text = mb_strtolower($text);
  8. $text = str_replace(" ", "", $text);
  9.  
  10. $length = mb_strlen($text) - 1;
  11. $halfLength = floor($length / 2);
  12.  
  13. for ($i = 0; $i <= $halfLength; $i++) {
  14. if (mb_substr($text, $i, 1) != mb_substr($text, $length - $i, 1)) {
  15. $result = "not palindrome";
  16. break;
  17. }
  18. }
  19.  
  20. echo "{$result}\n";
  21.  
Success #stdin #stdout 0.02s 52472KB
stdin
Standard input is empty
stdout
palindrome