Remove Duplicate elements from array in php
<?php
$duplicate = array(4,8,4,3,8,5,2,4,5,9,7,6,9);
$length = count($duplicate);
$unique = array();
foreach($duplicate as $value){
if(!in_array($value,$unique)){
$unique[] = $value;
}
}
echo"<pre>";
print_r($unique);
?>
Output:-
Array ( [0] => 4 [1] => 8 [2] => 3 [3] => 5 [4] => 2 [5] => 9 [6] => 7 [7] => 6 )
Comments
Post a Comment