I want to obtain this
dog-cat-mouse
From each one of those
- dog,cat,mouse
- dog, cat, mouse
- dog cat mouse
What i came up with is 2 preg_replace
$str = preg_replace('/[,\s]/', '-', $str);
$str = preg_replace('/--/', '-', $str);
works on my local server BUT does not work on production, it gives me
dog, cat, mouse -> dog--cat--mouse
which is not what I want