Last active
June 18, 2020 11:49
-
-
Save malikalichsan/760823689028c31e752bae141ff23567 to your computer and use it in GitHub Desktop.
#Jabar Digital Services PHP Question 1
This file contains 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($string) | |
{ | |
$string = str_replace(' ', '', $string); | |
$string = preg_replace('/[^A-Za-z0-9\-]/', '', $string); | |
$string = strtolower($string); | |
$reverse = strrev($string); | |
if ($string == $reverse) { | |
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