Trying to remove duplicate array elements without using array_unique. I am trying to use the array_flip method but that doesn't seem to be working for me. The Code that I have so far is:
$arr = array(
'a' => "one",
'b' => "two",
'c' => "three",
'd' => "two",
'e' => "four",
'f' => "five",
'g' => "three",
'h' => "two"
);
function removeDuplicates($arr) {
$arr = array_flip($arr);
$arr = array_flip($arr);
}
print_r(removeDuplicates($arr));
The output that I am trying to get ultimately is:
[a] => one
[e] => four
[f] => five
This is just purely for educational purposes as I am trying to find different ways to do it. Any help is great appreciated.
removeDuplicates
needs areturn $arr;
. – Rocket Hazmat May 30 '12 at 19:56