Guest User

Untitled

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