Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Palindrome
- {
- public static function isPalindrome($word)
- {
- $word = str_replace(' ', '', $word);
- $word = preg_replace('/[^A-Za-z0-9\-]/', '', $word);
- $word = strtolower($word);
- $reverse = strrev($word);
- if ($word == $reverse) {
- return true;
- }
- else {
- return false;
- }
- }
- }
- echo Palindrome::isPalindrome('Deleveled');
Add Comment
Please, Sign In to add comment