$txt = 'love food education health';
$txt = str_replace(' ', ',', $txt);

echo $txt;
Buyrun str_replace ile yapabilirsiniz.