You can use a combination of explode, array_chunk, array_mapandimplode
$words = explode(' ', $string);
$chunks = array_chunk($words, 2);
$chunks = array_map(function($arr) { return implode(' ', $arr); }, $chunks);
$str = implode(',', $chunks);
But he suggests that every word is shared by one space.
Another and probably simpler solution is preg_replaceas follows:
preg_replace('/(\S+\s+\S+)\s/', '$1,', $string)
(\S+\s+\S+)\s (\S+), (\S+), , . .
, :
a b c d e f g h i
\__/\__/\__/\__/
:
a b,c d,e f,g h,i