if you iterate over the first set of matches from this array, you can create your desired output easily using stripos to find occurances of , and explode to generate arrays from your , seperated values.