How might one determine whether or not a substring in a body of html is part of a hyperlink?
<p>strange problem here that I've been pondering.  I have a string that contains HTML, possibly with hyperlinks in it.  Consider the text below:</p>

<p><code>Hello this is my EXAMPLE string of html here's a &lt;tag&gt; and here's another &lt;/tag&gt;.  Blah blah I'm going to hyperlink some stuff with &lt;a href="http://www.example.com/&gt; anchor text &lt;/a&gt; and then finish my sentence.</code></p>

<p>As you can see above, the phrase <code>anchor text</code> is the anchor text for a hyperlink to <code>example.com</code>.</p>

<p>I want to be able to search for a substring like <code>anchor</code> or <code>example</code> and determine whether or not each occurrence is part of a hyperlink, whether it be anchor text, the url, or the <code>a</code> tag.</p>

<p>Preferably, there would be an array returned with a true/false for each occurrence of the search term.  Case-insensitive search would be good, and it would be nice if it returned the matching occurrence, so we'd know the case and such.  An ideal response for the above example would be something like this:</p>

<pre><code>$array[0][0] = "EXAMPLE"
$array[0][1] = false
$array[1][0] = "example"
$array[1][1] = true
</code></pre>

<p>The index of each occurrence might also be useful information to return.  Thanks!</p>
