In this program, you will find reverse of number 1) without using library function
2) by using strrev() library function
<?php
$n=1345;
$copy=$n;
$rev=0;
while($n>0)
{
/*It will find the reverse of the number.*/
$rev=$rev*10+$n%10;
$n=(int)($n/10);
}
echo "reverse of number $copy is:$rev";
?>
reverse of number 1345 is:5431
strrev() is function which is use for reversing string value.
<?php
$n=13456;
// convert integer into string
$n=(String)$n;
// reverse the String
$rev=strrev($n);
// convert string into integer
$rev=(int)$rev;
echo "reverse of number $n is:$rev";
?>
reverse of number 13456 is:65431