Removing Duplicates From an array
Following example will show how to remove duplicate from an array
$arr = array("one"=>1,"two"=>2,3,4,5,6,5,7,"one1"=>1,2);
$tempArr = array_flip ($arr);
$tempArr1 = array_flip ($tempArr);
print_r($tempArr1);
Explanation
array_flip() function will get an array as argument and return an array in flip order that means key and value are interchanged.If value is found n times , latest key will be return as value.
So in the above code
$tempArr = array_flip ($arr);
$tempArr will contain
Array ([1] => one1 [2] => 6 [3] => 0 [4] => 1 [5] => 4 [6] => 3 [7] => 5)
then again we do the flip
$tempArr1 = array_flip ($tempArr);
Now the duplicates are removed
