<?php
class Palindrome
{
public static function isPalindrome($word)
{
$string = str_replace(' ', '', $word);
$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('nitin');
?>
class Palindrome
{
public static function isPalindrome($word)
{
$string = str_replace(' ', '', $word);
$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('nitin');
?>
No comments:
Post a Comment