Sunday 7 August 2016

Check whether a word is Palindrome or not in PHP

PHP Function to test whether a given word is a palindrome or not. A Palindrome is a word which when reversed also gives the same word. This simple function helps in finding whether the given word is a palindrome or not.

function isWordPalindrome($word) {
    $word = str_replace(' ', '', $word);
    return $word == strrev($word);
}

No comments:

Post a Comment