I need to be able to detect cases where a string has words separated with commas and are missing space after comma. For example:
skiing, swimming,golf,bodysurfing,juggling, motorcylce,tennis
needs to be
skiing, swimming, golf, bodysurfing, juggling, motorcylce, tennis
I think I can use preg_replace for this, like
preg_replace($pattern, $replacement, $string);
Where my
$replacement = ", ";
I have a difficulty with the $pattern. I ONLY need to match a comma if there's no space right before and after it.