Is Palindrome Number
This algorithm check whether a given number is palindrome number or not. A palindrome number is a number such that if we reverse it, it will not change.
function Reverse($num)
{
$reverse = 0;
while ($num != 0)
{
$reverse *= 10;
$reverse += $num % 10;
$num = (int)($num / 10);
}
return $reverse;
}
function IsPalindromeNumber($num)
{
return $num == Reverse($num);
}
Example
$isPalindromeNumber = IsPalindromeNumber(-4554);
Output
True