Replacing an html page title
Posted: Wed Mar 23, 2005 4:25 am
I'm sure this is really simple but I just can't find a way to do it:
I have a template file for a website which naturally contains:
<title>website name</title>
What I need to do is change the page title to a product name, and up until now I have simply been using str_replace to change "website name" to "product name". However, now the template file is updated often and not by myself, and the title sometimes get changed. What I'm looking for is some code to find "<title>*anything*</title>" and change it to "<title>product name</title>".
From what I can tell preg_replace is the way to go, but I've not used it before and can't figure out how to apply it here. Can anyone give me a helping hand on this one?
Thanks in advance!
I have a template file for a website which naturally contains:
<title>website name</title>
What I need to do is change the page title to a product name, and up until now I have simply been using str_replace to change "website name" to "product name". However, now the template file is updated often and not by myself, and the title sometimes get changed. What I'm looking for is some code to find "<title>*anything*</title>" and change it to "<title>product name</title>".
From what I can tell preg_replace is the way to go, but I've not used it before and can't figure out how to apply it here. Can anyone give me a helping hand on this one?
Thanks in advance!