Guest User

Untitled

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