Jump to content

how annoying is str_replace?


tiddy

Recommended Posts

Hi,

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]
with:
[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.
Link to comment
https://forums.phpfreaks.com/topic/4774-how-annoying-is-str_replace/
Share on other sites

Archived

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

×
×
  • Create New...

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.