<?PHP
function replacelinks($doc){
$regmatches=array();
preg_match_all("/<a(.*?) href=[\"'](.+?)[\"'](.*?)>(.+?)<\/a>/", $doc, $regmatches);
foreach($regmatches[0] as $key => $data){
$doc=str_replace($regmatches[0][$key], myfunc($regmatches[2][$key], $regmatches[4][$key], $regmatches[1][$key] . $regmatches[3][$key]), $doc);
}
return $doc;
}
function myfunc ($url, $text, $attrib){
print $url . "<br>" . $text . "<br>" . $attrib;
}
?>
replace links
This replaces html links passed to the function with the result of "myfunc" which takes the link location, the link contents and any attributes as arguments.
(1) | by Jove on March 26th, 2008
An account is required to post comments and adaptations
COMMENTS AND ADAPTATIONS

Nice one - I've used it in a project already!
(unrated) | a comment by defproc on March 26th, 2008

This replaces html links passed to the function with the result of the specified function which takes the link location, the link contents and any attributes as arguments.
(unrated) | an adaptation by defproc on March 26th, 2008 | read entry | 1 comments | 0 adaptations
loading
