PHP Programs

Please click on 1-2 Ads to keep this website's Study Material FREE and regularly Updated.

Program 29: Write a PHP program to reverse a number.

rev_num.php

<!DOCTYPE html>
<html>
<head>
	<title>PHP Programs TutorialDuniya.com</title>
</head>
<body>
	<?php
		$num = 23456;  
		$revnum = 0;

		while ($num > 1)  
		{  
			$rem = $num % 10;  
			$revnum = ($revnum * 10) + $rem;  
			$num = ($num / 10);   
		}  

		echo "<br/>";
		echo "Reverse of  number 23456 is: $revnum";  
	?>
</body>
</html>



If you have any suggestion or found any error in the above program, then do let us know at [email protected] or just comment below.