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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.