Write a program to check number is palindrome or not

In this article, We’ll write a program to check the number is palindrome or not.

Palindrome number is a number which remains same when its digits are reversed.

For example, number 123321 is a palindrome number. after reversed we’ll get the same number.




    $number   = 123321;
    $sum      = 0;
    $pass_num = $number;
    while (floor($pass_num)) {  
      $rem = $pass_num % 10;  
      $sum = $sum * 10 + $rem;  
      $pass_num = $pass_num/10;  
    } 
    if ($number == $sum)
    echo "$number is a palindrome number";
    else
    echo "$number is a not palindrome number";

   // Output 123321 is a palindrome number

That’s it!. Please share your thoughts or suggestions in the comments below.

Leave a Reply

Your email address will not be published. Required fields are marked *