A palindrome is a word, number or even a phrase, which is symmetrical, for example when you read the letters in the word from from left to right and right to left, in other words, it’s the same backward as it is forwards. An example of a palindromes is “racecar” or even in numbers such as “12321”.

title tags
title tags

Returns true if the given string is a palindrome, false otherwise.

  • Check if the value of strrev($string) is equal to the passed $string.
function palindrome($string)
  return strrev($string) === (string) $string;
palindrome('racecar'); // true
palindrome(2221222); // true

CC0-1.0 license