Interview QuestionsCategory: PHPProgram to find palindrome in PHP.
bestonetechnologies Staff asked 1 year ago

Write a program to find palindrome in PHP.

1 Answers
bestonetechnologies Staff answered 1 year ago

<?php
$a = 121;
$rev = 0;
$rem = 0;
$temp = $a;
while($a > 0) {
$rem = $a % 10;
$rev = $rev * 10 + $rem;
$a = intval($a / 10);
}
if($rev == $temp) {
echo “Number is palindrome”;
} else {
echo “Number is NOT palindrome”;
}
?>

Your Answer

19 + 19 =