Removing Duplicates From an array
The following code shows how to remove the duplicates from array.
$arr = array(1,2,3,4,5,5,4,2,11,12,2);
$arr1 = array();
for($i = 0; $i < count($arr); $i++){
$val = $arr[$i];
if(!in_array($val,$arr1)){
array_push($arr1,$val);
}
}
print_r($arr1);
$arr = $arr1;
In the above code, we just stored the unique values to the temporary array called $arr1.
