I have a php variable that comes from a form that needs tidying up. I hope you can help.
The variable contains a list of items (possibly two or three word items with a space in between words).
I want to convert it to a comma separated list with no superfluous white space. I want the divisions to fall only at commas, semi-colons or new-lines. Blank cannot be an item.
Here's a comprehensive example (with a deliberately messy input):
Variable In: "dog, cat ,car,tea pot,, ,,, ;;(++NEW LINE++)fly, cake"
Variable Out "dog,cat,car,tea pot,fly,cake"
Can anyone help?