Remove The Duplicate Values From An Array in PHP
The below program is to remove the duplicate values from an array using PHP array_unique() function. The PHP echo statement is used to output the result on the screen. An array is a single variable which can store multiple values at a time. The PHP array_unique() function is used to remove the duplicate elements from an array.
Example:
<!DOCTYPE html>
<html>
<body>
<?php
$arr = array("London","Paris","Switzerland","Switzerland","Scotland");
print_r(array_unique($arr));
?>
</body>
</html>
Output:
Array ( [0] => London [1] => Paris [2] => Switzerland [4] => Scotland )