Skip to content

Instantly share code, notes, and snippets.

@candrasetiadi
Created January 7, 2019 15:05
Show Gist options
  • Save candrasetiadi/f453f3cd9a931bfbffd5b19ce4e434c3 to your computer and use it in GitHub Desktop.
Save candrasetiadi/f453f3cd9a931bfbffd5b19ce4e434c3 to your computer and use it in GitHub Desktop.
candra-jabar-digital-service
<?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