Hey,
I thought i had it all figured out, and then it all went wrong.. Im trying to replace all & symbols within a URL to %26.
ie i have html
<td><a href="http://www.shop.com/view.php?category=5&product=32&source=mailout"></td>
would become
<td><a href="http://www.shop.com/view.php?category=5%26product=32%26source=mailout"></td>
I need to do this because its part of a link tracker, forward the user to http://www.whatever.com/redirect.php?URL=http://www.shop.com/view.php?category=5&source=mailout
once it reaches the the & it thinks its the end of the URL variable.
the code with a regular expression i came up with is below.
$regexp = "{(<a[&]+)&}i";
while (preg_match($regexp, $html) > 0) {
$html = preg_replace($regexp, "\$1%26", $html);
}
it seems to work on basic tests, but not when inside tables and stuff.
can anyone help??
cheers,
Craig