Try it, it works with large arrays:
$original = array('one', 'two', 'three', 'four', 'five', 'two', 'four'); $filtered = array(); foreach ($original as $key => $value){ if(in_array($value, $filtered)){ continue; } array_push($filtered, $value); } print_r($filtered);
Outputs:
Array ( [0] => one [1] => two [2] => three [3] => four [4] => five )
source share