Hi,
i am setting up our enewsletter system so that when we send it it automatically searches through the text and changes the link to a different one with an idenifier and logs it in a db table. I can then point all links to a page which records that the link has been used and redirects them to the original link from the table.
I've got the header redirect working fine but i need to beable to change the url. I tried preg_replace to just add in some text before the address and just make the original address a &_get variable but this falls down if the link contains a '&' eg http://www.something.com?link=http:/...m?rel=1&rel2=2
the rel2 is seen as a separate variable and not part of link, which i guess makes sense as it hits the & and thinks its different.
so now i'm thinking of changing all of the address for another using something like this
Only problem is it only finds the first url in the string. How do i make it change for everyone it finds.Code:<?php $data1 = "This is one website <a href=\"example.com\">blah</a> oh but there is also this one <a href=\"example2.com\">blah</a>"; preg_match('/\="(.*?)\">/', $data1, $matches); // here we would insert the url into the database and generate a random number for the url to replace it with. $domain = $matches[1]; //just echo out the link for testing echo $domain; ?>
any help is much appreciated. thanks





Bookmarks