Paste Search Dynamic
isPalindrome
  1. <?php
  2.  
  3. function isPalindrome($string)
  4. {
  5.     $middlePoint = strlen($string) / 2;
  6.     return (strcmp(substr($string, 0, $middlePoint), strrev(substr($string, -$middlePoint))) == 0);
  7. }
  8.  
  9. var_dump(isPalindrome("А роза упала на лапу Азора"));
  10. var_dump(isPalindrome("hello"));
  11. var_dump(isPalindrome("10021"));
  12. var_dump(isPalindrome("10001"));
  13. var_dump(isPalindrome("2001"));
  14. var_dump(isPalindrome("1001"));
  15.  
  16. ?>
Parsed in 0.017 seconds