$str = 'key1 p1, p2 ,p3 key2 p4,p5';
$m = preg_split('~(key1|key2)~', $str, -1, PREG_SPLIT_DELIM_CAPTURE);
for ($i = count($m) - 1; $i >= 2; $i-=2) {
$result[$m[$i-1]] = $m[$i];
}
print_r($result);
/* Array
(
[key1] => p1, p2 ,p3
[key2] => p4,p5
)
*/
$str = 'key1 p1, p2 ,p3 key2 p4,p5';
preg_match_all('~(key1|key2)(.*?)(?=$|(?1))~', $str, $m);
$result = array_combine($m[1], $m[2]);
print_r($result);