In PHP, you can use array_unique() A function for removing duplicate elements from an array. This function takes an array as a parameter and returns a new array containing only the unique elements from the original array. Here is an example:
$myArray = array('apple', 'orange', 'banana', 'orange', 'grape', 'apple');
$uniqueArray = array_unique($myArray);
print_r($uniqueArray);Output:
Array
(
[0] => apple
[1] => orange
[2] => banana
[4] => grape
)In the above example, the original array $myArray Contains some duplicate elements, for example 'orange' 和 'apple'By invoking array_unique() By applying the function, we obtain a new array. $uniqueArrayThis contains only the distinct elements from the original array.