Last active
May 24, 2019 17:24
-
-
Save akatgelar/e3864dabbf09e0e996181c6a58548b26 to your computer and use it in GitHub Desktop.
PHP #1 Palindrome - Answer for https://www.testdome.com/questions/php/palindrome/7320?visibility=1&skillId=5
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); | |
$word_ = strrev($word); | |
if ($word_ == $word) { | |
return true; | |
} | |
else { | |
return false; | |
} | |
} | |
} | |
echo Palindrome::isPalindrome('Deleveled'); |
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
I'm baffled, for some reason this doesn't pass and I cannot get anything to pass. I feel like the tests are broken... WDYT?
my code was: