I need to change some of the strings to SEO-friendly slugs. I think I'm pretty close with this:
str_replace(array(" ", "&", "(", ")", ".", ",", " - ", "'"), array("-", ""), strtolower($str))
However there are couple of cases that I still have issues with. It's when a string has a dash or & as in:
I & GN Hospital and Nurses' Quarters
produces i--gn-hospital-and-nurses-quarters
instead of desired
i-gn-hospital-and-nurses-quarters
Also I would like to strip anything enclosed in () before creating a slug. For example:
Mary Kate Hunter (November 8, 1866 - April 15, 1945)
should become mary-kate-hunter
I think I'll need another str_replace first to remove it, before creating slug, and possibly use some sort of regex. Or is there a better way?