$array = [
'a' => 4,
's' => 5,
'd' => 6,
];
$onlyKeys = ['s','d'];
$filteredArray = array_filter($array, function($v) use ($onlyKeys) {
return in_array($v, $onlyKeys);
}, ARRAY_FILTER_USE_KEY);
prinr_r($filteredArray); // ['s' => 5, 'd' => 6]