The array_unique()
returns the unique values with duplicate values removed.
PHP array_unique() Function has the following syntax.
array array_unique ( array arr )
Parameter | Is Required | Description |
---|---|---|
array | Required. | Array to filter |
sortingtype | Optional. | How to compare the array elements/items. |
Possible values for sortingtype:
Returns the unique values with duplicate values removed
<?PHP
$toppings2 = array("A", "B", "B", "C","java2s.com");
$toppings2 = array_unique($toppings2);
print_r($toppings2);
?>
The code above generates the following result.