Skip to content

Instantly share code, notes, and snippets.

@arbaieffendi
Created May 15, 2019 08:16
Show Gist options
  • Save arbaieffendi/05ee1c62c3fbb33e4ec1fd7e8a15a2ad to your computer and use it in GitHub Desktop.
Save arbaieffendi/05ee1c62c3fbb33e4ec1fd7e8a15a2ad to your computer and use it in GitHub Desktop.
Palindrome Class written in PHP 7.1.9. - isPalindrome
<?php
class Palindrome
{
public static function isPalindrome($word)
{
$word = strtolower($word);
$wordArray = str_split($word);
for ($i = 0; $i <= count($wordArray); $i++) {
$wordBackward = $wordBackward.$wordArray[count($wordArray)-$i];
}
//echo "Forward : ".$word."\n";
//echo "Backward : ".$wordBackward."\n";
if ($word == $wordBackward)
return true;
else
return false;
}
}
echo Palindrome::isPalindrome('Deleveled');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment