You owe me a blow job.
It could be shorter, but that takes time, more thought and money.
PHP Code:
<?php
$string = 'a,b,c,d';
foreach(explode(',', $string) as $match) {
if(in_array($match, array('a','c'))) $matches[] = $match;
}
print_r($matches); // Here are your items.
?>