I had a strange coding situation where I needed to have the URI become the title of the page being viewed. I couldn’t think of another way to do it but now I need to format that URI and can’t figure out how to accomplish it. It is a WordPress site so the URI is pretty clean. What I want to do is capitalize the letter of the first word and then a space, dash or pipe delimiter to separate out the title.
So this obviously gives me the URI:
<title><?php echo ($_SERVER['REQUEST_URI']) ?></title>
which gives me something like /test-catalog/diagnosis/flu. What I want to display is Test Catalog – Diagnosis – Flu
Thank you.
as a résumé of the previous answers: