LS,
I'm using the following code to add <span>
tags behind <a>
tags.
$html = preg_replace("~<a.*?href=\"$url\".*?>.*?</a>~i", "$0<span>test</span>", $html);
The code is working fine for regular links (ie. http://www.google.com/), but it will not perform a replace when the contents of $url are $link$/3/
.
This is example code to show the (mis)behaviour:
<?php
$urls = array();
$urls[] = '$link$/3/';
$urls[] = 'http://www.google.com/';
$html = '<a href="$link/3/">Test Link</a>' . "\n" . '<a href="http://www.google.com/">Google</a>';
foreach($urls as $url) {
$html = preg_replace("~<a.*?href=\"$url\".*?>.*?</a>~i", "$0<span>test</span>", $html);
}
echo $html;
?>
And this is the output it produces:
<a href="$link$/3/">Test Link</a>
<a href="http://www.google.com/">Google</a><span>test</span>
Kind regards,
Matthias Vance