Jump to content


This topic is now archived and is closed to further replies.


how annoying is str_replace?

Recommended Posts


I'm looking to create something like rinkworks dialectizer (http://www.rinkworks.com/dialect) and i need to replace all the <a href="[relative address]"> with <a href="[thispage]?page=[entire address]"> how can i do this without replacing all the <a href="[entire link]"> with <a href="[thispage]?page=[domain][entire address]">.
For example I have:
[i]<a href="somepage.html">[/i]
which I want to replace with:
[i]<a href="thispage.php?page=www.domain.com/somepage.html">[/i]
and I want to replace:
[i]<a href="www.domain.com/somepage.html">[/i]
[i]<a href="thispage.php?page=www.domain.com/somepage.html">[/i]
How do I do this without getting:
[i]<a href="thispage.php?page=www.domain.comwww.domain.com/somepage.html">[/i]
I am using str_replace('href="','href="thispage.php?page=' . $page,$pagestr);
where $page is the address and $pagestr is the content of that page.

Thanks for any help.

Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.