PHP Programs

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

Program 36: Write a program to print the elements of an array in reverse order.

rev_array.php

<!DOCTYPE html>  
<html>
<head>	
	<title>PHP Programs TutorialDuniya.com</title>
</head>
<body>  
	<?php  
		$a1 = array(11, 12, 13, 14, 15);   

		print("Original Array : <br>");  
		for ($i = 0; $i < count($a1); $i++) 
		{   
			print($a1[$i] . " ");   
		}    

		print("Array in reverse order: <br>");  
		for ($i = count($a1)-1; $i >= 0; $i--) 
		{   
			print($a1[$i] . " "); ;   
		}      
	?>
</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.