How to remove duplicate values from Array in PHP?

I am explaining you, how to remove duplicate values from Array in PHP. it is simple to delete duplicate values from an PHP Array.
PHP provide pre-define function array_unique that can remove duplicate values from Array. with the use of pre-define function array_unique() we can get only unique value from array.

Example:

<?php 
$example_array = [10,3,12,10,23,54,78,64,75];

$example_array_updated = array_unique($example_array);


print_r($example_array_updated); 
?>

Result:


Array
(
    [0] => 10
    [1] => 3
    [2] => 12
    [4] => 23
    [5] => 54
    [6] => 78
    [7] => 64
    [8] => 75
)

One thought to “How to remove duplicate values from Array in PHP?”

Leave a Reply

Your email address will not be published. Required fields are marked *

− 3 = 1