Last active
June 8, 2019 15:41
-
-
Save kenjipm/422eadeef05fb5ddfd059c4e70889897 to your computer and use it in GitHub Desktop.
A palindrome is a word that reads the same backward or forward.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Palindrome | |
{ | |
public static function isPalindrome($word) | |
{ | |
$word = strtolower($word); | |
$length = strlen($word); | |
for($i = 0; $i < $length; $i++) | |
{ | |
if ($word[$i] != $word[$length - 1 - $i]) | |
{ | |
return false; | |
} | |
} | |
return true; | |
} | |
} | |
echo Palindrome::isPalindrome('Deleveled'); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment