PHP program to check for palindrome number (using for loop)

Last updated:13th Aug 2022

In this example, you will check whether the number is palindrome or not by using for loop.121, 101, and 12321 are palindrome numbers.

When the original number and reverse of the original number are the same then the number is called a palindrome.

function ispalindrome($n){
    for(; $n>0; $n=(int)($n/10))
        /*It will find the reverse of number.*/
    // Compare the reverse of number with the copy variable (original number)
        echo $copy.' is palindrome number';
        echo $copy.' is not palindrome number';


121 is palindrome number