PHP program to find palindrome

In this tutorial I’m going to show you how to find a word or a sentence is a Palindrome in PHP.

You may find scripts online but most of them are difficult to understand and almost all of them used loops to find it, but this php script I have written is very simple and not used any loops.

Let’s see the script:

Read the comments in the script to understand what is happening.

Few palindrome words and sentences to check:

1. madam
2. civic
3. Madam, I’m Adam
4. A man, a plan, a canal: Panama.
5. No lemon, no melon.

The basic concept is reversing the entered string and comparing the string with the original string using  (==) comparison operator. if both the original string and reversed string matched, then it is a Palindrome.

See the demo in here:


Related Posts

5 thoughts on “PHP program to find palindrome

Leave a Reply