What you want to do is probalby best handled with a regex. As long as what you are looking for falls into a pattern then this is the easiest way to get it.
preg_match("/CCC(.*[,]),/", $string, $matches);
Or something like that. You may have to play around with the regex to make it work properly.