Skip to content

Instantly share code, notes, and snippets.

@akatgelar
Last active May 24, 2019 17:24
Show Gist options
  • Save akatgelar/e3864dabbf09e0e996181c6a58548b26 to your computer and use it in GitHub Desktop.
Save akatgelar/e3864dabbf09e0e996181c6a58548b26 to your computer and use it in GitHub Desktop.
<?php
class Palindrome
{
public static function isPalindrome($word)
{
$word = str_replace(' ', '', $word);
$word = preg_replace('/[^A-Za-z0-9\-]/', '', $word);
$word = strtolower($word);
$word_ = strrev($word);
if ($word_ == $word) {
return true;
}
else {
return false;
}
}
}
echo Palindrome::isPalindrome('Deleveled');
@joshbutkovic
Copy link

Ok scratch that your answer does work, I guess it wants you actually call the function, nm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment