To remove duplicate values from an array in PHP, you can use the array_unique()
function. Here is an example:
$array = [1, 2, 3, 2, 4, 3];
$uniqueArray = array_unique($array);
print_r($uniqueArray);
Output:
Array
(
[0] => 1
[1] => 2
[2] => 3
[4] => 4
)
In the above example, the array_unique()
function removes all duplicate values from the array, and the resulting array named $uniqueArray
contains only the unique values.