Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Palindrome
- {
- public static function isPalindrome($word)
- {
- $word = strtolower($word);
- for($i = 0; $i < ceil(strlen($word)/2); $i++){
- $left = substr($word, $i, 1);
- $right = substr($word, -($i+1), 1);
- if($left!== $right) {
- return FALSE;
- }
- }
- return TRUE;
- }
- }
- echo Palindrome::isPalindrome('Deleveled')."\n";
- echo Palindrome::isPalindrome('Madam');
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement