fork(2) download
  1. <?php
  2. function utf8_strrev(string $str)
  3. {
  4. preg_match_all('/./us', $str, $ar);
  5. return join('', array_reverse($ar[0]));
  6. }
  7.  
  8. $text = "А роза упала на лапу Азора";
  9. $textToCompare = mb_strtolower(str_replace(" ", "", $text));
  10. echo utf8_strrev($textToCompare) === $textToCompare ? "палиндром" : "не палиндром";
Success #stdin #stdout 0.01s 24764KB
stdin
Standard input is empty
stdout
палиндром