Is there a faster way to do this? It is pretty slow when you are checking lots of data $dataArray = array(0=>4, 1=>5, 2=>6, 3=>7, 4=>8); $checkArray = array(0=>4, 1=>5, 2=>6); foreach($dataArray as $data){ if(!in_array($data, $checkArray)){ $returnData[] = $data; } } print_r($returnData); PHP:
yes theirs a function already for this theirfore no need to reinvent the wheel - array_diff() -> http://php.net/manual/en/function.array-diff.php