48. PHP Program to Remove Duplicate Elements from Array.
How does this program work?
- In this program we are going to learn about how to Remove Duplicate Elements from Array using PHP.
- In this program array-unique() function is used to remove duplicate elements from given array.
Here is the code
<html>
<head>
<title>PHP Program To Remove Duplicate Elements from Array</title>
</head>
<body>
<?php
$numbers = array (5, 1, 5, 9, 1, 4);
echo "Given elements of array : \n";
foreach($numbers as $value)
{
echo $value . " ";
}
echo "After remove duplicate elements : \n";
$new = array_unique($numbers);
foreach ($new as $value)
{
echo $value . " ";
}
return 0;
?>
</body>
</html>