Hi, 

     Today, we will learn how to reverse a number in PHP.

First consider the number 1234. Here we need to get last number first. Hence i am using the modulus operator with divisor value  as 10  for getting the remainder value to move from last into first place.  Shall we go through the program to reverse a number in PHP now?  

Program: Reverse a Number in PHP 

<?php
$m = 1234; $r=0;
for($i=0; $i<3; $i++)
{
$r=$m%10;
echo $r;
$m = $m/10;
}
$m=$m%10;
echo $m;
?>

Output:

4321