I’m busy with a website and for an element I use preg_replace to replace all the spaces with a dash.
preg_replace('/\\s/', '-', $item_replace_en[0])
And this works great but now i have a new problem. A user enterd the following “Music / Film”.
the output is “Music-/-Film” and i want it to be “Music-Film”.
How can I accomplish this?
It looks like you’re trying to generate a string that can be used as a URL.
There a numerous of scenarios that can happen when a user adds a title that you want to convert to a URL safe string. Someone could for instance use this:
Should return:
Is your code ready for that? In that case you can use this function: