$array_new = []; foreach($array_two as $key) { if(array_key_exists($key, $array_one)) { $array_new[$key] = $array_one[$key]; } }