How can array_unique() be used effectively in PHP to filter out duplicate values?

When dealing with an array that may contain duplicate values, you can use the array_unique() function in PHP to filter out these duplicates and return a new array with only unique values. This function removes duplicate values while preserving the original order of elements in the array.

// Original array with duplicate values
$array = [1, 2, 2, 3, 4, 4, 5];

// Filter out duplicate values
$uniqueArray = array_unique($array);

// Output the unique array
print_r($uniqueArray);