PHP Programs

TheFestFever.com

Our aim is to connect students from campuses all over Delhi by making them aware of all Technical, Cultural, Management fests, workshops, Seminars organized by every college in Delhi.

Join Us Now

Program 35: Write a program to print the duplicate elements of an array.

duplicate.php

<!DOCTYPE html>  
<html> 
<head>	
	<title>PHP Programs TutorialDuniya.com</title>
</head>
<body>
	<?php
		$arr1 = array(10, 2, 3, 4, 18, 10, 8, 18, 3);   
	
		print("Duplicate elements in given array are : <br>");  
	
		for($i = 0; $i < count($arr1); $i++) 
		{  
			for($j = $i + 1; $j < count($arr1); $j++) 
			{  
				if($arr1[$i] == $arr1[$j])  
					print($arr1[$j] . "<br>");  
			}  
		}  
	?>
</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.