Q:

Removal of special characters, a comma separated text, PHP

I got my text variable which is user-specified, normally, user should enter the tags which has to look following: 
"food, community, relationship"

but if user type for example 
"food;;[]'.'.;@$#community,,,-;,,,relationship"

the script should change it into: 
"food, community, relationship".

How can I get this done?

A:

how about:
$str = "-----music,,,,,,,,games;'235@#%@#%media";
$arr = preg_split("/\W+/", $str, -1, PREG_SPLIT_NO_EMPTY);
$str = implode(', ', $arr);
echo $str,"\n";

output:
music, games, 235, media

You could adapt the \W to which characters you need to keep.

