Archive

Posts Tagged ‘hyperlink’

How to extract text from a hyperlink (remove anchor tags)

January 14, 2009 3 comments

This php code snippet shows how to retrieve the text part of a hyperlink:

$a_hrf = "/<a>]*?href=[\"\']?([^\'\">]*)[\'\"]?[^>]*?>/";
$a_close ="/<\/a>/";
$hyper_link = '<a href="http://www.example.com">Great Site!</a>';
$text = preg_replace($a_hrf, '', $hyper_link);
$text = preg_replace($a_close, '', $text);
Categories: programming, Techie Tags: , , ,