Ok that was my bad, misread what you were trying to do. thought you only were replacing each once.
function links($string){
$pattern = "/<ilink ([0-9]+)>(.*?)<ilink>/";
while(preg_match($pattern, $string, $matches)){
$id = $matches['1'];
$title = $matches['2'];
$replacement = "<a href='?pageid=$id' target='_top'>$title</a>";
$string = preg_replace($pattern, $replacement, $string, 1);
}
$pattern = "/<elink ([0-9]+)\>(.*?)<elink>/";
while(preg_match($pattern, $string, $matches)){
$id = $matches['1'];
$title = $matches['2'];
$replacement = "<a href='links.php?link_name=$id' target='_blank'>$title</a>";
$string = preg_replace($pattern, $replacement, $string, 1);
}
$pattern = "/<flink ([0-9]+)\>(.*?)<flink>/";
while(preg_match($pattern, $string, $matches)){
$id = $matches['1'];
$title = $matches['2'];
$replacement = "<a href='links.php?linkname=$id' target='_blank'>$title</a>";
$string = preg_replace($pattern, $replacement, $string, 1);
}
return $string;
}
will work for you lol