Jump to content

extract text from an anchor


snakebit

Recommended Posts

You can do it with javascript if the link has an id by using this:

 

var anchortext=document.getElementById('thelink').innerHTML;

 

Seeing as this was posted in the regex forum, it's quite unlikely he is seeking a Javascript solution.

 

Could could get it like this:

preg_match('#<a.*>(.*)</a>#iU', $string, $matches);
$text = $matches[1];

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.