When I replace spaces, dots and commas of a string, it sometimes happens that I get double hyphens.
For example turns check out the 1. place
into check-out-the-1--place
How can I avoid that? I want it to be check-out-the-1-place
- so that there only is one hyphen between each word.
Here is my code:
str_replace([' ', ',', '.','?'], '-', strtolower($pathname));
Right now, I know why it returns the double-hyphens, but I don't know how to work around that.
Can someone help me out?