Skip to content

Instantly share code, notes, and snippets.

@malikalichsan
Last active June 18, 2020 11:49
Show Gist options
  • Save malikalichsan/760823689028c31e752bae141ff23567 to your computer and use it in GitHub Desktop.
Save malikalichsan/760823689028c31e752bae141ff23567 to your computer and use it in GitHub Desktop.
#Jabar Digital Services PHP Question 1
<?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