PHP array_diff


array_diff(array1,array2) function compares two arrays and returns all elements in array1 but not in array2.

<?PHP
	$arr1=array(1,2,3,4,5,6,7,8,9);
	$arr2=array(2,4,6,8);
	$arr3=array_diff($arr1,$arr2);
	foreach($arr3 as $element) echo "$element, "; //1, 3, 5, 7, 9,
?>

It can also take a 3rd array parameter, all the elements in the 1st array as well as in the 3rd array will be deleted.
<?PHP
	$arr1=array(1,2,3,4,5,6,7,8,9);
	$arr2=array(2,4,6,8);
	$arr3=array_diff($arr1,$arr2,array(1,3));
	foreach($arr3 as $element) echo "$element, "; //5, 7, 9, 
?>

Similarly, more array parameters can be taken, all elements in the 1st array and also in the other arrays will be deleted.
<?PHP
	$arr1=array(1,2,3,4,5,6,7,8,9);
	$arr2=array(2,4,6,8);
	$arr3=array_diff($arr1,$arr2,array(1,3),array(5));
	foreach($arr3 as $element) echo "$element, "; //7, 9, 
?>