Friday, 9 August 2013

Alter urls within a tag

Alter urls within a tag

I'm hit a bit of a noob wall and i'm not certain how to get over it.
When displaying some content from a DB, this content will contain HTML
tags. One of those tags is <a> link.
It's href will equal any of the following.
http://www.example.com
http://www.example.com/
http://www.example.com/some/other/stuff
/some/other/stuff

/
www.example.com
www.example.com/
What i need to do, and i've tried the logic using str_replace() but i cant
get it 100% working... is turn all the above links to this.
http://www.example.com/2012_2013
http://www.example.com/2012_2013/
/2012_2013/some/other/stuff

/2012_2013
www.example.com/2012_2013
www.example.com/2012_2013/
my issue is mainly with turning /some/other/stuff into
/2012_2013/some/other/stuff
when i have no idea what /this/could/be so how do i find it and prepend
/2012_2013
Thanks in advance.

No comments:

Post a Comment