I am trying to covert html to text for an email. I would like the link to appear as 'link text' ( url address ). Here's what I have: It doesn't seem to work quite right. It is ok it there is just one link.
Any ideas?
#Replace all links with text
$html = 'link 1 is <A href="http://slashdot.org">here</A>
<BR>link 2 <A href="http://www.uit.no" target=_blank>is here</A>
<BR><A href="http://www.yahoo.com">link 3 is here</A>';
preg_match_all("/<a.+href=[\"|'](.+?)[\"|'].*?>(.+?)<\/a>/i",$html,$links);
if (is_array($links)) {
for ($i=0;$i<count($links[0]);$i++) {
echo '<br>'.$links[0][$i];
$html = str_replace($links[0][$i],$links[2][$i].' ( '.$links[1][$i].' )',$html);
}
}