SHARE
TWEET

Untitled

a guest May 23rd, 2019 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class Palindrome
  2. {
  3.     public static function isPalindrome($word)
  4.     {
  5.         $word = strtolower($word);
  6.        
  7.         if(strrev($word) != $word){
  8.             return false;
  9.         }
  10.        
  11.         for ($i = 0, $j = strlen($word)-1; $i < $j; $i++, $j--) {
  12.             if ($word[$i] !== $word[$j]) {
  13.               return false;
  14.             }
  15.         return true;
  16.         }
  17.     }
  18. }
  19.  
  20. echo Palindrome::isPalindrome('Deleveled');
  21. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top