Advertisement
Guest User

Untitled

a guest
May 24th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. <?php
  2. class Palindrome
  3. {
  4. public static function isPalindrome($word)
  5. {
  6. $word = str_replace(' ', '', $word);
  7.  
  8. $word = preg_replace('/[^A-Za-z0-9\-]/', '', $word);
  9.  
  10. $word = strtolower($word);
  11.  
  12. $reverse = strrev($word);
  13.  
  14. if ($word == $reverse) {
  15. return true;
  16. }
  17. else {
  18. return false;
  19. }
  20. }
  21. }
  22.  
  23. echo Palindrome::isPalindrome('Deleveled');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement