Skip to content

Instantly share code, notes, and snippets.

@kenjipm
Last active June 8, 2019 15:41
Show Gist options
  • Save kenjipm/422eadeef05fb5ddfd059c4e70889897 to your computer and use it in GitHub Desktop.
Save kenjipm/422eadeef05fb5ddfd059c4e70889897 to your computer and use it in GitHub Desktop.
A palindrome is a word that reads the same backward or forward.
<?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