I've created a function so I can display a specific part of a URL:
function PageName() {
return substr($_SERVER["REQUEST_URI"],strrpos($_SERVER["SCRIPT_NAME"],"/")+10,strrpos($_SERVER["SCRIPT_NAME"],"/")-4);
}
This will allow me to show The+Title if the URL is domain.com/my-pages/The+Title/go/
It works perfectly if the title is one word, but in the above example it is two words with a + sign.
I've tried to add str_replace("+"," ",PageName) at the end to replace the plus sign with an empty space, but doesn't seem to work:
function PageName() {
return substr($_SERVER["REQUEST_URI"],strrpos($_SERVER["SCRIPT_NAME"],"/")+10,strrpos($_SERVER["SCRIPT_NAME"],"/")-4,str_replace("+"," ",PageName));
}
Any ideas?
str_replace.str_replace("+"," ",PageName())- you need to call the function. I would actually dourldecode(PageName())