Created
January 7, 2019 15:05
-
-
Save candrasetiadi/f453f3cd9a931bfbffd5b19ce4e434c3 to your computer and use it in GitHub Desktop.
candra-jabar-digital-service
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 = str_replace(' ', '', $word); | |
$word = preg_replace('/[^A-Za-z0-9\-]/', '', $word); | |
$word = strtolower($word); | |
$reverse = strrev($word); | |
if ($word == $reverse) { | |
return true; | |
} | |
return false; | |
} | |
} | |
echo Palindrome::isPalindrome('Deleveled'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment