It's a good function for sure

I only see one issue..
If the link has any extra info it isn't going to match. For example:
Code:
$url = 'http://www.crazyfilth.com/';
$anchor_text = 'Porn Videos';
$html = '<a href="http://www.crazyfilth.com/?PHPSESSID=777" id="extra">Porn Videos</a>';