SHARE
TWEET

Untitled

a guest May 25th, 2019 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. class Palindrome
  3. {
  4.     public static function isPalindrome($word)
  5.     {
  6.         $word = strtolower($word);
  7.        
  8.         $wordArray = str_split($word);
  9.         for ($i = 0; $i <= count($wordArray); $i++) {
  10.             $wordBackward = $wordBackward.$wordArray[count($wordArray)-$i];
  11.         }
  12.        
  13.         //echo "Forward  : ".$word."\n";
  14.         //echo "Backward : ".$wordBackward."\n";
  15.        
  16.         if ($word == $wordBackward)
  17.             return true;
  18.         else
  19.             return false;
  20.     }
  21. }
  22.  
  23. echo Palindrome::isPalindrome('Deleveled');
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